mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-25 05:14:56 +09:00
Issue 2694: Add support for CAST and CONVERT functions
git-svn-id: http://xe-core.googlecode.com/svn/branches/luminous@12237 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
6f66f4f8b9
commit
156d7655e9
4 changed files with 39 additions and 1 deletions
|
|
@ -144,7 +144,7 @@
|
|||
if(strpos($match,')') !== false) continue;
|
||||
if(in_array($match, array(',', '.'))) continue;
|
||||
if($brackets == $total_brackets){
|
||||
if(!is_numeric($match)) {
|
||||
if(!is_numeric($match) && !in_array(strtoupper($match), array('UNSIGNED', 'INTEGER', 'AS'))) {
|
||||
$match = $this->escapeColumnExpression($match);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -380,4 +380,26 @@ class MysqlSelectTest extends MysqlTest {
|
|||
limit 5";
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add support for CAST / CONVERT function
|
||||
*/
|
||||
function testCast()
|
||||
{
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/cast.xml";
|
||||
$argsString = '';
|
||||
$expected = "select cast(`document_srl` as unsigned integer) from `xe_documents` as `documents`";
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add support for CAST / CONVERT function
|
||||
*/
|
||||
function testConvert()
|
||||
{
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/convert.xml";
|
||||
$argsString = '';
|
||||
$expected = "select convert(`document_srl`, unsigned integer) from `xe_documents` as `documents`";
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
}
|
||||
8
tests/classes/db/db/xml_query/mysql/data/cast.xml
Normal file
8
tests/classes/db/db/xml_query/mysql/data/cast.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<query id="getDocumentListWithinComment" action="select">
|
||||
<tables>
|
||||
<table name="documents" alias="documents" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="CAST(document_srl as UNSIGNED INTEGER)" />
|
||||
</columns>
|
||||
</query>
|
||||
8
tests/classes/db/db/xml_query/mysql/data/convert.xml
Normal file
8
tests/classes/db/db/xml_query/mysql/data/convert.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<query id="getDocumentListWithinComment" action="select">
|
||||
<tables>
|
||||
<table name="documents" alias="documents" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="CONVERT(document_srl, UNSIGNED INTEGER)" />
|
||||
</columns>
|
||||
</query>
|
||||
Loading…
Add table
Add a link
Reference in a new issue