Issue 2288: Bug in XML Query with "like" clause

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.3.1@11081 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2012-08-24 10:06:32 +00:00
parent 8ee56fff9f
commit 5ee72554f1
3 changed files with 79 additions and 0 deletions

View file

@ -57,6 +57,7 @@
// If default value is column name, it should be escaped
if($isColumnName = (strpos($condition->attrs->default, '.') !== false
&& strpos($condition->attrs->default, '.') !== 0
&& strpos($condition->attrs->default, '%') === false ))
{
$condition->attrs->default = $dbParser->parseColumnName($condition->attrs->default);

View file

@ -342,4 +342,27 @@ class MysqlSelectTest extends MysqlTest {
$this->_test($xml_file, $argsString, $expected);
}
/**
* Like with image extension
*/
function testLikeImageExtension()
{
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/like_image_extension.xml";
$argsString = '';
$expected = "select `files`.`upload_target_srl` as `document_srl`
from `xe_files` as `files`
, `xe_documents` as `documents`
where (
`files`.`upload_target_srl` = `documents`.`document_srl`
and (`files`.`source_filename` like '%.jpg'
or `files`.`source_filename` like '%.gif'
or `files`.`source_filename` like '%.png'))
and `documents`.`list_order` <= 2100000000
group by `files`.`upload_target_srl`
order by `documents`.`list_order` asc
limit 5";
$this->_test($xml_file, $argsString, $expected);
}
}

View file

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<query id="getImages" action="select">
<tables>
<table name="files" alias="files"/>
<table name="documents" alias="documents"/>
</tables>
<columns>
<column name="files.upload_target_srl" alias="document_srl"/>
</columns>
<conditions>
<condition operation="in" column="files.module_srl" var="module_srls" filter="number" />
<condition operation="equal" column="files.direct_download" var="direct_download" pipe="and" />
<condition operation="equal" column="files.isvalid" var="isvalid" pipe="and" />
<condition operation="equal" column="files.upload_target_srl" var="documents.document_srl" pipe="and" />
<group pipe="and">
<condition operation="like_tail" column="files.source_filename" var="s_filename1" default=".jpg" pipe="or" />
<condition operation="like_tail" column="files.source_filename" var="s_filename2" default=".gif" pipe="or" />
<condition operation="like_tail" column="files.source_filename" var="s_filename3" default=".png" pipe="or" />
</group>
</conditions>
<groups>
<group column="files.upload_target_srl" />
</groups>
<navigation>
<index var="list_order" default="documents.list_order" order="asc" />
<list_count var="list_count" default="5" />
</navigation>
</query>