From 49aa45b45e1cc83cb61d1524ba32d6c188dac2e1 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 6 Jul 2012 16:22:21 +0300 Subject: Fix a few join() bugs --- .../codeigniter/database/query_builder/join_test.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') diff --git a/tests/codeigniter/database/query_builder/join_test.php b/tests/codeigniter/database/query_builder/join_test.php index b8cf2a822..6d5fc64af 100644 --- a/tests/codeigniter/database/query_builder/join_test.php +++ b/tests/codeigniter/database/query_builder/join_test.php @@ -35,4 +35,24 @@ class Join_test extends CI_TestCase { $this->assertEquals('Developer', $job_user[0]['job_name']); } + // ------------------------------------------------------------------------ + + public function test_join_escape_multiple_conditions() + { + // We just need a valid query produced, not one that makes sense + $fields = array($this->db->protect_identifiers('table1.field1'), $this->db->protect_identifiers('table2.field2')); + + $expected = 'SELECT '.implode(', ', $fields) + ."\nFROM ".$this->db->escape_identifiers('table1') + ."\nLEFT JOIN ".$this->db->escape_identifiers('table2').' ON '.implode(' = ', $fields) + .' AND '.$fields[0]." = 'foo' AND ".$fields[1].' = 0'; + + $result = $this->db->select('table1.field1, table2.field2') + ->from('table1') + ->join('table2', "table1.field1 = table2.field2 AND table1.field1 = 'foo' AND table2.field2 = 0", 'LEFT') + ->get_compiled_select(); + + $this->assertEquals($sql, $result); + } + } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From b6490f507e6c0c470b91d50eb550cda96199d591 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 6 Jul 2012 16:32:16 +0300 Subject: Fix a join() test ... doh --- tests/codeigniter/database/query_builder/join_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/codeigniter/database/query_builder/join_test.php b/tests/codeigniter/database/query_builder/join_test.php index 6d5fc64af..25bd4accb 100644 --- a/tests/codeigniter/database/query_builder/join_test.php +++ b/tests/codeigniter/database/query_builder/join_test.php @@ -52,7 +52,7 @@ class Join_test extends CI_TestCase { ->join('table2', "table1.field1 = table2.field2 AND table1.field1 = 'foo' AND table2.field2 = 0", 'LEFT') ->get_compiled_select(); - $this->assertEquals($sql, $result); + $this->assertEquals($expected, $result); } } \ No newline at end of file -- cgit v1.2.3-24-g4f1b