From 576eaa0cff7a5e051aa672034e596e90f65fc1a9 Mon Sep 17 00:00:00 2001 From: brunoais Date: Mon, 16 Mar 2015 11:31:51 +0000 Subject: [PATCH] [feature/sql-bool-builder] Adding the IS operator to predicted operators PHPBB3-13652 --- phpBB/phpbb/db/driver/driver.php | 18 ++++++++++++++++++ tests/dbal/boolean_processor_test.php | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/phpBB/phpbb/db/driver/driver.php b/phpBB/phpbb/db/driver/driver.php index ce69ef6a52..4d78c84c8a 100644 --- a/phpBB/phpbb/db/driver/driver.php +++ b/phpBB/phpbb/db/driver/driver.php @@ -866,6 +866,24 @@ abstract class driver implements driver_interface break; + case 'IS_NOT': + + $condition[1] = 'IS NOT'; + + // no break + case 'IS': + + // If the value is NULL, the string of it is the empty string ('') which is not the intended result. + // this should solve that + if ($condition[2] === null) + { + $condition[2] = 'NULL'; + } + + $condition = implode(' ', $condition); + + break; + default: $condition = implode(' ', $condition); diff --git a/tests/dbal/boolean_processor_test.php b/tests/dbal/boolean_processor_test.php index 2ba3f6ff22..5e044797f8 100644 --- a/tests/dbal/boolean_processor_test.php +++ b/tests/dbal/boolean_processor_test.php @@ -153,7 +153,7 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case ), array('AND', array('ug.group_id', '=', 1), - array('b.ban_id', 'IS NOT', NULL), + array('b.ban_id', 'IS_NOT', NULL), ), ), array('u.user_id', '=', 'ug.user_id'),