From c368fa189c317b86ab2c518adebddd8bfa0b2099 Mon Sep 17 00:00:00 2001 From: ucorina Date: Tue, 4 Oct 2011 15:07:23 +0000 Subject: [PATCH] Issue 344 - error occurrence when using substr() in XML Query condition. git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9483 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- .../xmlquery/tags/condition/ConditionTag.class.php | 2 +- test-phpUnit/db/xml_query/mysql/MysqlSelectTest.php | 7 +++++++ test-phpUnit/db/xml_query/mysql/data/substring.xml | 11 +++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test-phpUnit/db/xml_query/mysql/data/substring.xml diff --git a/classes/xml/xmlquery/tags/condition/ConditionTag.class.php b/classes/xml/xmlquery/tags/condition/ConditionTag.class.php index e895aae95..8c2c26a2c 100644 --- a/classes/xml/xmlquery/tags/condition/ConditionTag.class.php +++ b/classes/xml/xmlquery/tags/condition/ConditionTag.class.php @@ -21,7 +21,7 @@ $this->operation = $condition->attrs->operation; $this->pipe = $condition->attrs->pipe; $dbParser = DB::getParser(); - $this->column_name = $dbParser->parseColumnName($condition->attrs->column); + $this->column_name = $dbParser->parseExpression($condition->attrs->column); // If default value is column name, it should be escaped if($isColumnName = strpos($condition->attrs->default, '.')){ diff --git a/test-phpUnit/db/xml_query/mysql/MysqlSelectTest.php b/test-phpUnit/db/xml_query/mysql/MysqlSelectTest.php index 773c4b990..97fc5a4b0 100644 --- a/test-phpUnit/db/xml_query/mysql/MysqlSelectTest.php +++ b/test-phpUnit/db/xml_query/mysql/MysqlSelectTest.php @@ -80,4 +80,11 @@ and `item`.`item_srl` = 10'; $this->_test($xml_file, $argsString, $expected); } + + function testSubstring(){ + $xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/substring.xml"; + $argsString = '$args->var_start_mmdd = "1102"; '; + $expected = 'select * from `xe_member` as `member` where substr(`extra_vars_t1`.`value`,5,4) >= 1102'; + $this->_test($xml_file, $argsString, $expected); + } } \ No newline at end of file diff --git a/test-phpUnit/db/xml_query/mysql/data/substring.xml b/test-phpUnit/db/xml_query/mysql/data/substring.xml new file mode 100644 index 000000000..fef155bec --- /dev/null +++ b/test-phpUnit/db/xml_query/mysql/data/substring.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file