From ff679cc517be09515358985dae18ea64c86c5eec Mon Sep 17 00:00:00 2001 From: ucorina Date: Mon, 18 Jul 2011 15:17:49 +0000 Subject: [PATCH] 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 --- .../xml/xmlquery/argument/ConditionArgument.class.php | 3 +++ .../xml/xmlquery/argument/ConditionArgumentTest.php | 11 +++++++++++ .../xml/xmlquery/queryargument/QueryArgumentTest.php | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/classes/xml/xmlquery/argument/ConditionArgument.class.php b/classes/xml/xmlquery/argument/ConditionArgument.class.php index b5d3a280b..2e2267793 100644 --- a/classes/xml/xmlquery/argument/ConditionArgument.class.php +++ b/classes/xml/xmlquery/argument/ConditionArgument.class.php @@ -31,6 +31,9 @@ case 'like' : $this->value = '%'.$value.'%'; break; + case 'in': + if(!is_array($value)) $this->value = array($value); + break; } /* //if(!in_array($operation,array('in','notin','between')) && is_array($value)){ diff --git a/test-phpUnit/classes/xml/xmlquery/argument/ConditionArgumentTest.php b/test-phpUnit/classes/xml/xmlquery/argument/ConditionArgumentTest.php index d2f386b0b..116cf232a 100644 --- a/test-phpUnit/classes/xml/xmlquery/argument/ConditionArgumentTest.php +++ b/test-phpUnit/classes/xml/xmlquery/argument/ConditionArgumentTest.php @@ -5,6 +5,17 @@ */ 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(). */ diff --git a/test-phpUnit/classes/xml/xmlquery/queryargument/QueryArgumentTest.php b/test-phpUnit/classes/xml/xmlquery/queryargument/QueryArgumentTest.php index d8911682f..b13e953db 100644 --- a/test-phpUnit/classes/xml/xmlquery/queryargument/QueryArgumentTest.php +++ b/test-phpUnit/classes/xml/xmlquery/queryargument/QueryArgumentTest.php @@ -7,7 +7,7 @@ class QueryArgumentTest extends CubridTest { var $xmlPath = "data/"; - function QueryArgumentClass(){ + function QueryArgumentTest(){ $this->xmlPath = str_replace('QueryArgumentTest.php', '', str_replace('\\', '/', __FILE__)) . $this->xmlPath; }