From 30a9d499abc29799104c19d9cd46b0102a97e03b Mon Sep 17 00:00:00 2001 From: ucorina Date: Wed, 30 Nov 2011 09:40:52 +0000 Subject: [PATCH] Issue 1103: problem of not in query git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9898 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- .../ConditionWithoutArgument.class.php | 6 ++-- .../db/db/xml_query/mysql/MysqlSelectTest.php | 22 +++++++++++++ .../mysql/data/homepage.getNewestComments.xml | 31 +++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 tests/classes/db/db/xml_query/mysql/data/homepage.getNewestComments.xml diff --git a/classes/db/queryparts/condition/ConditionWithoutArgument.class.php b/classes/db/queryparts/condition/ConditionWithoutArgument.class.php index 68ee35103..950235020 100644 --- a/classes/db/queryparts/condition/ConditionWithoutArgument.class.php +++ b/classes/db/queryparts/condition/ConditionWithoutArgument.class.php @@ -3,8 +3,10 @@ class ConditionWithoutArgument extends Condition { function ConditionWithoutArgument($column_name, $argument, $operation, $pipe = ""){ parent::Condition($column_name, $argument, $operation, $pipe); - if(in_array($operation, array('in', 'notin'))) - $this->_value = '('. $argument .')'; + if(in_array($operation, array('in', 'notin'))){ + if(is_array($argument)) $argument = implode($argument, ','); + $this->_value = '('. $argument .')'; + } else $this->_value = $argument; diff --git a/tests/classes/db/db/xml_query/mysql/MysqlSelectTest.php b/tests/classes/db/db/xml_query/mysql/MysqlSelectTest.php index cd330b846..296b9635d 100644 --- a/tests/classes/db/db/xml_query/mysql/MysqlSelectTest.php +++ b/tests/classes/db/db/xml_query/mysql/MysqlSelectTest.php @@ -207,4 +207,26 @@ limit 20'; $this->_test($xml_file, $argsString, $expected); } + + function test_homepage_getNewestComments(){ + $xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/homepage.getNewestComments.xml"; + $argsString = ';'; + $expected = 'select `sites`.`domain` as `domain` + , `comments`.* + from `xe_homepages` as `homepages` + , `xe_sites` as `sites` + , `xe_comments` as `comments` + , `xe_modules` as `modules` + left join `xe_module_grants` as `module_grants` + on `module_grants`.`module_srl` = `modules`.`module_srl` + and `module_grants`.`name` = \'access\' + and `module_grants`.`group_srl` not in (0,-1) + where (`homepages`.`site_srl` = `sites`.`site_srl` + and `homepages`.`site_srl` = `modules`.`site_srl` + and `comments`.`module_srl` = `modules`.`module_srl` + and `module_grants`.`group_srl` is null) + and `comments`.`list_order` <= 2100000000 + order by `comments`.`list_order` asc limit 0, 5'; + $this->_test($xml_file, $argsString, $expected); + } } \ No newline at end of file diff --git a/tests/classes/db/db/xml_query/mysql/data/homepage.getNewestComments.xml b/tests/classes/db/db/xml_query/mysql/data/homepage.getNewestComments.xml new file mode 100644 index 000000000..9bf58ae90 --- /dev/null +++ b/tests/classes/db/db/xml_query/mysql/data/homepage.getNewestComments.xml @@ -0,0 +1,31 @@ + + + +
+
+
+
+ + + + + +
+
+ + + + + + + + + + + + + + + + +