From e1ae5aab976f3369ab9e239d2850998bac22e517 Mon Sep 17 00:00:00 2001 From: ucorina Date: Wed, 4 Jul 2012 09:00:38 +0000 Subject: [PATCH] Issue 2114: XML Query 'null' operation does not work git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10831 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- .../queryparts/condition/Condition.class.php | 4 ++ .../db/db/xml_query/mysql/MysqlSelectTest.php | 40 ++++++++++++++++++- .../mysql/data/page.pageTypeNotNullCheck.xml | 20 ++++++++++ .../mysql/data/page.pageTypeNullCheck.xml | 20 ++++++++++ 4 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 tests/classes/db/db/xml_query/mysql/data/page.pageTypeNotNullCheck.xml create mode 100644 tests/classes/db/db/xml_query/mysql/data/page.pageTypeNullCheck.xml diff --git a/classes/db/queryparts/condition/Condition.class.php b/classes/db/queryparts/condition/Condition.class.php index c4675ad31..3f4c0a3a1 100644 --- a/classes/db/queryparts/condition/Condition.class.php +++ b/classes/db/queryparts/condition/Condition.class.php @@ -14,6 +14,7 @@ /** * operation can use 'equal', 'more', 'excess', 'less', 'below', 'like_tail', 'like_prefix', 'like', 'notlike_tail', * 'notlike_prefix', 'notlike', 'in', 'notin', 'not_in', 'and', 'or', 'xor', 'not', 'notequal', 'between' + * 'null', 'notnull' * @var string */ var $operation; @@ -129,6 +130,9 @@ case 'between' : if(!is_array($this->_value)) { $this->_show = false; break;} if(count($this->_value)!=2) {$this->_show = false; break;} + case 'null': + case 'notnull': + break; default: // If operation is not one of the above, means the condition is invalid $this->_show = false; diff --git a/tests/classes/db/db/xml_query/mysql/MysqlSelectTest.php b/tests/classes/db/db/xml_query/mysql/MysqlSelectTest.php index 9405200ef..eaee29382 100644 --- a/tests/classes/db/db/xml_query/mysql/MysqlSelectTest.php +++ b/tests/classes/db/db/xml_query/mysql/MysqlSelectTest.php @@ -2,7 +2,7 @@ class MysqlSelectTest extends MysqlTest { - function _test($xml_file, $argsString, $expected, $columnList = null) { + function _test($xml_file, $argsString, $expected, $columnList = NULL) { $this->_testQuery($xml_file, $argsString, $expected, 'getSelectSql', $columnList); } @@ -291,4 +291,42 @@ class MysqlSelectTest extends MysqlTest { $expected = 'select `modules`.`site_srl` as `site_srl`, `modules`.`mid` as `mid`, `documents`.* from `xe_modules` as `modules`, `xe_documents` as `documents` where (`documents`.`module_srl` in (345709,345710,345711,345728,345707,345670,345667,49113,16551,345679,50394,350665,345680,381846,381852,381917,345708,349028,345666,17173,49117,345671,345714,345665,349893,345696,345713,351967,330919,345685,16754,349027,348787,345672,350239,345697,345674,291882,345678,345729,345675,345721,345676,381867,294605,381864,345673,355113,353624,345681,345683,345668,345677,12424,158716,47498,101835,273679,142558,13818,12311,8723,78670,18919,365075,13833,14293,15891,27823,14291,177818,81000,11788,18918,13859,14102,14136,255783,134367,385619,317170,330312) and `modules`.`module_srl` = `documents`.`module_srl`) and `documents`.`list_order` <= 2100000000 order by `documents`.`list_order` asc limit 10'; $this->_test($xml_file, $argsString, $expected); } + + /** + * Issue 2114 + * 'Null' operation is ignored + */ + function test_null() + { + $xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/page.pageTypeNullCheck.xml"; + $argsString = ' '; + $expected = 'select `m`.`module_srl`, `m`.`mid`, `ev`.`value` + from `xe_modules` as `m` + left join `xe_module_extra_vars` as `ev` + on `ev`.`name` = \'page_type\' + and `m`.`module_srl` = `ev`.`module_srl` + where `m`.`module` = \'page\' + and `ev`.`value` is null + '; + $this->_test($xml_file, $argsString, $expected); + } + + /** + * Issue 2114 + * 'Notnull' operation is ignored + */ + function test_notnull() + { + $xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/page.pageTypeNotNullCheck.xml"; + $argsString = ' '; + $expected = 'select `m`.`module_srl`, `m`.`mid`, `ev`.`value` + from `xe_modules` as `m` + left join `xe_module_extra_vars` as `ev` + on `ev`.`name` = \'page_type\' + and `m`.`module_srl` = `ev`.`module_srl` + where `m`.`module` = \'page\' + and `ev`.`value` is not null + '; + $this->_test($xml_file, $argsString, $expected); + } } \ No newline at end of file diff --git a/tests/classes/db/db/xml_query/mysql/data/page.pageTypeNotNullCheck.xml b/tests/classes/db/db/xml_query/mysql/data/page.pageTypeNotNullCheck.xml new file mode 100644 index 000000000..bff829baa --- /dev/null +++ b/tests/classes/db/db/xml_query/mysql/data/page.pageTypeNotNullCheck.xml @@ -0,0 +1,20 @@ + + + +
+ + + + +
+
+ + + + + + + + + +
diff --git a/tests/classes/db/db/xml_query/mysql/data/page.pageTypeNullCheck.xml b/tests/classes/db/db/xml_query/mysql/data/page.pageTypeNullCheck.xml new file mode 100644 index 000000000..0fefc0f27 --- /dev/null +++ b/tests/classes/db/db/xml_query/mysql/data/page.pageTypeNullCheck.xml @@ -0,0 +1,20 @@ + + + +
+ + + + +
+
+ + + + + + + + + +