Fixed query argument bug - for in operation, if there was only one element, the brackets weren't added. Added unit test for this.

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8605 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2011-07-18 15:17:49 +00:00
parent 5dc0b9c36c
commit ff679cc517
3 changed files with 15 additions and 1 deletions

View file

@ -31,6 +31,9 @@
case 'like' : case 'like' :
$this->value = '%'.$value.'%'; $this->value = '%'.$value.'%';
break; break;
case 'in':
if(!is_array($value)) $this->value = array($value);
break;
} }
/* /*
//if(!in_array($operation,array('in','notin','between')) && is_array($value)){ //if(!in_array($operation,array('in','notin','between')) && is_array($value)){

View file

@ -5,6 +5,17 @@
*/ */
class ConditionArgumentTest extends CubridTest { class ConditionArgumentTest extends CubridTest {
function testIn(){
$args->document_srl = 1234;
$document_srl_argument = new ConditionArgument('document_srl', $args->document_srl, 'in');
$document_srl_argument->checkNotNull();
$document_srl_argument->createConditionValue();
if(!$document_srl_argument->isValid()) return $document_srl_argument->getErrorMessage();
$document_srl_argument->setColumnType('number');
$condition = new Condition('"extra_vars"."document_srl"',$document_srl_argument,"in", 'and');
$this->assertEquals('and "extra_vars"."document_srl" in (1234)', $condition->toString());
}
/** /**
* @todo Implement testCreateConditionValue(). * @todo Implement testCreateConditionValue().
*/ */

View file

@ -7,7 +7,7 @@ class QueryArgumentTest extends CubridTest {
var $xmlPath = "data/"; var $xmlPath = "data/";
function QueryArgumentClass(){ function QueryArgumentTest(){
$this->xmlPath = str_replace('QueryArgumentTest.php', '', str_replace('\\', '/', __FILE__)) . $this->xmlPath; $this->xmlPath = str_replace('QueryArgumentTest.php', '', str_replace('\\', '/', __FILE__)) . $this->xmlPath;
} }