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
This commit is contained in:
ucorina 2011-11-30 09:40:52 +00:00
parent def75c83ef
commit 30a9d499ab
3 changed files with 57 additions and 2 deletions

View file

@ -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;

View file

@ -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);
}
}

View file

@ -0,0 +1,31 @@
<query id="getNewestComments" action="select">
<tables>
<table name="homepages" />
<table name="sites" />
<table name="comments" />
<table name="modules" />
<table name="module_grants" alias="module_grants" type="left join">
<conditions>
<condition operation="equal" column="module_grants.module_srl" default="modules.module_srl" />
<condition operation="equal" column="module_grants.name" default="access" pipe="and" />
<condition operation="notin" column="module_grants.group_srl" default="0,-1" pipe="and" />
</conditions>
</table>
</tables>
<columns>
<column name="sites.domain" alias="domain" />
<column name="comments.*" />
</columns>
<conditions>
<condition operation="equal" column="homepages.site_srl" default="sites.site_srl" notnull="notnull" />
<condition operation="equal" column="homepages.site_srl" default="modules.site_srl" notnull="notnull" pipe="and" />
<condition operation="equal" column="comments.module_srl" default="modules.module_srl" notnull="notnull" pipe="and" />
<condition operation="null" column="module_grants.group_srl" pipe="and" />
</conditions>
<navigation>
<index var="sort_index" default="comments.list_order" order="asc" />
<list_count var="list_count" default="5" />
<page_count var="page_count" default="5" />
<page var="page" default="1" />
</navigation>
</query>