mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-06 18:21:39 +09:00
Issue 2064: XML Query - added support for not_in
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10776 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
7fd8f55141
commit
40a2d4a6ed
6 changed files with 77 additions and 3 deletions
|
|
@ -13,7 +13,7 @@
|
|||
var $argument;
|
||||
/**
|
||||
* operation can use 'equal', 'more', 'excess', 'less', 'below', 'like_tail', 'like_prefix', 'like', 'notlike_tail',
|
||||
* 'notlike_prefix', 'notlike', 'in', 'notin', 'and', 'or', 'xor', 'not', 'notequal', 'between'
|
||||
* 'notlike_prefix', 'notlike', 'in', 'notin', 'not_in', 'and', 'or', 'xor', 'not', 'notequal', 'between'
|
||||
* @var string
|
||||
*/
|
||||
var $operation;
|
||||
|
|
@ -115,6 +115,7 @@
|
|||
case 'notlike' :
|
||||
case 'in' :
|
||||
case 'notin' :
|
||||
case 'not_in' :
|
||||
case 'and':
|
||||
case 'or':
|
||||
case 'xor':
|
||||
|
|
@ -177,6 +178,7 @@
|
|||
return $name.' in '.$value;
|
||||
break;
|
||||
case 'notin' :
|
||||
case 'not_in' :
|
||||
return $name.' not in '.$value;
|
||||
break;
|
||||
case 'notequal' :
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
function ConditionWithoutArgument($column_name, $argument, $operation, $pipe = ""){
|
||||
parent::Condition($column_name, $argument, $operation, $pipe);
|
||||
if(in_array($operation, array('in', 'notin'))){
|
||||
if(in_array($operation, array('in', 'notin', 'not_in'))){
|
||||
if(is_array($argument)) $argument = implode($argument, ',');
|
||||
$this->_value = '('. $argument .')';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
|
||||
function ConditionArgument($name, $value, $operation){
|
||||
if(isset($value) && in_array($operation, array('in', 'notin', 'between')) && !is_array($value) && $value != ''){
|
||||
if(isset($value) && in_array($operation, array('in', 'notin','not_in', 'between')) && !is_array($value) && $value != ''){
|
||||
$value = str_replace(' ', '', $value);
|
||||
$value = str_replace('\'', '', $value);
|
||||
$value = explode(',', $value);
|
||||
|
|
@ -57,6 +57,7 @@
|
|||
if(!is_array($value)) $this->value = array($value);
|
||||
break;
|
||||
case 'notin':
|
||||
case 'not_in':
|
||||
if(!is_array($value)) $this->value = array($value);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -262,4 +262,33 @@ class MysqlSelectTest extends MysqlTest {
|
|||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Issue 2064
|
||||
* Queries should support both notin and not_in as valid operations
|
||||
*/
|
||||
function test_not_in() {
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/document.getNewestDocuments.xml";
|
||||
$argsString = '$args->module_srl = "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";
|
||||
$args->sort_index = "documents.list_order";
|
||||
$args->order_type = "asc";
|
||||
$args->list_count = 10;
|
||||
';
|
||||
$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` not in (0) and `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 2064
|
||||
* Query condition should be ignored if operation is invalid
|
||||
*/
|
||||
function test_invalid_condition_operation() {
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/document.getNewestDocumentsInvalid.xml";
|
||||
$argsString = '$args->module_srl = "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";
|
||||
$args->sort_index = "documents.list_order";
|
||||
$args->order_type = "asc";
|
||||
$args->list_count = 10;
|
||||
';
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<query id="getNewestDocuments" action="select">
|
||||
<tables>
|
||||
<table name="modules" />
|
||||
<table name="documents" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="modules.site_srl" alias="site_srl"/>
|
||||
<column name="modules.mid" alias="mid"/>
|
||||
<column name="documents.*" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="modules.site_srl" var="site_srl" />
|
||||
<condition operation="not_in" column="documents.module_srl" default="0" pipe="and" />
|
||||
<condition operation="in" column="documents.module_srl" var="module_srl" filter="number" pipe="and" />
|
||||
<condition operation="equal" column="modules.module_srl" default="documents.module_srl" filter="number" pipe="and" />
|
||||
</conditions>
|
||||
<navigation>
|
||||
<index var="sort_index" default="documents.list_order" order="order_type" />
|
||||
<list_count var="list_count" default="20" />
|
||||
</navigation>
|
||||
</query>
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<query id="getNewestDocuments" action="select">
|
||||
<tables>
|
||||
<table name="modules" />
|
||||
<table name="documents" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="modules.site_srl" alias="site_srl"/>
|
||||
<column name="modules.mid" alias="mid"/>
|
||||
<column name="documents.*" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="modules.site_srl" var="site_srl" />
|
||||
<condition operation="random_stuff" column="documents.module_srl" default="0" pipe="and" />
|
||||
<condition operation="in" column="documents.module_srl" var="module_srl" filter="number" pipe="and" />
|
||||
<condition operation="equal" column="modules.module_srl" default="documents.module_srl" filter="number" pipe="and" />
|
||||
</conditions>
|
||||
<navigation>
|
||||
<index var="sort_index" default="documents.list_order" order="order_type" />
|
||||
<list_count var="list_count" default="20" />
|
||||
</navigation>
|
||||
</query>
|
||||
Loading…
Add table
Add a link
Reference in a new issue