summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/database
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2016-02-11 22:49:37 +0100
committerAndrey Andreev <narf@devilix.net>2016-02-11 22:49:37 +0100
commitc6011941511e706c3a3d44151eccda7d0b472007 (patch)
treeb3431a0af08dac844f4dc86ca0b4dc09326ca8f2 /tests/codeigniter/database
parenta54a2b90bf057d7883ea7506d78a1073478ea4cf (diff)
Fix #4449
Diffstat (limited to 'tests/codeigniter/database')
-rw-r--r--tests/codeigniter/database/query_builder/join_test.php27
1 files changed, 25 insertions, 2 deletions
diff --git a/tests/codeigniter/database/query_builder/join_test.php b/tests/codeigniter/database/query_builder/join_test.php
index 58cb21492..54b2a4e18 100644
--- a/tests/codeigniter/database/query_builder/join_test.php
+++ b/tests/codeigniter/database/query_builder/join_test.php
@@ -37,6 +37,29 @@ class Join_test extends CI_TestCase {
// ------------------------------------------------------------------------
+ public function test_join_escape_is_null()
+ {
+ $expected = 'SELECT '.$this->db->escape_identifiers('field')
+ ."\nFROM ".$this->db->escape_identifiers('table1')
+ ."\nJOIN ".$this->db->escape_identifiers('table2').' ON '.$this->db->escape_identifiers('field').' IS NULL';
+
+ $this->assertEquals(
+ $expected,
+ $this->db->select('field')->from('table1')->join('table2', 'field IS NULL')->get_compiled_select()
+ );
+
+ $expected = 'SELECT '.$this->db->escape_identifiers('field')
+ ."\nFROM ".$this->db->escape_identifiers('table1')
+ ."\nJOIN ".$this->db->escape_identifiers('table2').' ON '.$this->db->escape_identifiers('field').' IS NOT NULL';
+
+ $this->assertEquals(
+ $expected,
+ $this->db->select('field')->from('table1')->join('table2', 'field IS NOT NULL')->get_compiled_select()
+ );
+ }
+
+ // ------------------------------------------------------------------------
+
public function test_join_escape_multiple_conditions()
{
// We just need a valid query produced, not one that makes sense
@@ -65,11 +88,11 @@ class Join_test extends CI_TestCase {
$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)';
+ .' AND ('.$fields[0]." = 'foo' OR ".$fields[1].' IS NULL)';
$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')
+ ->join('table2', "table1.field1 = table2.field2 AND (table1.field1 = 'foo' OR table2.field2 IS NULL)", 'RIGHT')
->get_compiled_select();
$this->assertEquals($expected, $result);