Skip to content

Commit 20cdb55

Browse files
committed
Don't escape NULL. Fixes #1169
1 parent 8a3ad86 commit 20cdb55

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

system/Database/BaseBuilder.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,19 @@ public function select($select = '*', $escape = null)
260260
if ($val !== '')
261261
{
262262
$this->QBSelect[] = $val;
263+
264+
/*
265+
* When doing 'SELECT NULL as field_alias FROM table'
266+
* null gets taken as a field, and therefore escaped
267+
* with backticks.
268+
* This prevents NULL being escaped
269+
* @see https://github.com/bcit-ci/CodeIgniter4/issues/1169
270+
*/
271+
if ( strtoupper(mb_substr(trim($val), 0, 4)) == 'NULL')
272+
{
273+
$escape = false;
274+
}
275+
263276
$this->QBNoEscape[] = $escape;
264277
}
265278
}

0 commit comments

Comments
 (0)