From 95bd763784f215a5cb4c38a4bc1caf5ac3c8f72d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 5 Feb 2016 14:15:45 +0200 Subject: Fix another regression caused by 805eddaefd9503b5dbbd924bd6da66e29c4768f3 Also added a unit test for #4431 --- .../codeigniter/database/query_builder/join_test.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/codeigniter/database') diff --git a/tests/codeigniter/database/query_builder/join_test.php b/tests/codeigniter/database/query_builder/join_test.php index 25bd4accb..58cb21492 100644 --- a/tests/codeigniter/database/query_builder/join_test.php +++ b/tests/codeigniter/database/query_builder/join_test.php @@ -55,4 +55,24 @@ class Join_test extends CI_TestCase { $this->assertEquals($expected, $result); } + // ------------------------------------------------------------------------ + + public function test_join_escape_multiple_conditions_with_parentheses() + { + // 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') + ."\nRIGHT JOIN ".$this->db->escape_identifiers('table2').' ON '.implode(' = ', $fields) + .' AND ('.$fields[0]." = 'foo' OR ".$fields[1].' = 0)'; + + $result = $this->db->select('table1.field1, table2.field2') + ->from('table1') + ->join('table2', "table1.field1 = table2.field2 AND (table1.field1 = 'foo' OR table2.field2 = 0)", 'RIGHT') + ->get_compiled_select(); + + $this->assertEquals($expected, $result); + } + } \ No newline at end of file -- cgit v1.2.3-24-g4f1b