mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 19:21:40 +09:00
Issue 1669: [1.5.2] Query problem if there are columns have a same name and different types in joined tables.
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10432 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
9453348cb1
commit
51220d52d0
4 changed files with 328 additions and 246 deletions
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
|
||||
class MysqlSelectTest extends MysqlTest {
|
||||
class MysqlSelectTest extends MysqlTest {
|
||||
|
||||
function _test($xml_file, $argsString, $expected, $columnList = null){
|
||||
$this->_testQuery($xml_file, $argsString, $expected, 'getSelectSql', $columnList);
|
||||
}
|
||||
function _test($xml_file, $argsString, $expected, $columnList = null) {
|
||||
$this->_testQuery($xml_file, $argsString, $expected, 'getSelectSql', $columnList);
|
||||
}
|
||||
|
||||
function testConditionWithVarAndColumnDefaultValue_WithoutArgument(){
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/resource.getLatestItem.xml";
|
||||
$argsString = '$args->item_srl = "";';
|
||||
$expected = 'select `package`.`module_srl` as `module_srl`
|
||||
function testConditionWithVarAndColumnDefaultValue_WithoutArgument() {
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/resource.getLatestItem.xml";
|
||||
$argsString = '$args->item_srl = "";';
|
||||
$expected = 'select `package`.`module_srl` as `module_srl`
|
||||
, `package`.`status` as `status`
|
||||
, `package`.`category_srl` as `category_srl`
|
||||
, `package`.`member_srl` as `member_srl`
|
||||
|
|
@ -40,13 +40,13 @@
|
|||
, `xe_resource_items` as `item`
|
||||
where `package`.`member_srl` = `member`.`member_srl`
|
||||
and `item`.`item_srl` = `package`.`latest_item_srl`';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
function testConditionWithVarAndColumnDefaultValue_WithArgument(){
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/resource.getLatestItem.xml";
|
||||
$argsString = '$args->item_srl = "10";';
|
||||
$expected = 'select `package`.`module_srl` as `module_srl`
|
||||
function testConditionWithVarAndColumnDefaultValue_WithArgument() {
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/resource.getLatestItem.xml";
|
||||
$argsString = '$args->item_srl = "10";';
|
||||
$expected = 'select `package`.`module_srl` as `module_srl`
|
||||
, `package`.`status` as `status`
|
||||
, `package`.`category_srl` as `category_srl`
|
||||
, `package`.`member_srl` as `member_srl`
|
||||
|
|
@ -77,20 +77,20 @@
|
|||
, `xe_resource_items` as `item`
|
||||
where `package`.`member_srl` = `member`.`member_srl`
|
||||
and `item`.`item_srl` = 10';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
$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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
function testResource_getLatestItemList(){
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/resource.getLatestItemList.xml";
|
||||
$argsString = '';
|
||||
$expected = 'select `package`.`module_srl` as `module_srl`
|
||||
function testResource_getLatestItemList() {
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/resource.getLatestItemList.xml";
|
||||
$argsString = '';
|
||||
$expected = 'select `package`.`module_srl` as `module_srl`
|
||||
, `package`.`status` as `status`
|
||||
, `package`.`category_srl` as `category_srl`
|
||||
, `package`.`member_srl` as `member_srl`
|
||||
|
|
@ -130,71 +130,71 @@
|
|||
and `package`.`update_order` <= 2100000000
|
||||
order by `package`.`update_order` asc
|
||||
limit 0, 20';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
function test_Syndication_getGrantedModules(){
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/syndication.getGrantedModules.xml";
|
||||
$argsString = '';
|
||||
$expected = 'select `module_srl`
|
||||
function test_Syndication_getGrantedModules() {
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/syndication.getGrantedModules.xml";
|
||||
$argsString = '';
|
||||
$expected = 'select `module_srl`
|
||||
from `xe_module_grants` as `module_grants`
|
||||
where `name` in (\'access\',\'view\',\'list\')
|
||||
and (`group_srl` >= 1 or `group_srl` = -1 or `group_srl` = -2) group by `module_srl`';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
function test_Like_Clause(){
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/opage.getOpageList.like.xml";
|
||||
$argsString = '$args->s_mid = "test";';
|
||||
$expected = 'select *
|
||||
function test_Like_Clause() {
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/opage.getOpageList.like.xml";
|
||||
$argsString = '$args->s_mid = "test";';
|
||||
$expected = 'select *
|
||||
from `xe_modules` as `modules`
|
||||
where `module` = \'opage\'
|
||||
and (`mid` like \'%test%\')
|
||||
order by `module_srl` desc
|
||||
limit 0, 20';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
function test_NotLike_Clause(){
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/opage.getOpageList.notlike.xml";
|
||||
$argsString = '$args->s_mid = "test";';
|
||||
$expected = 'select *
|
||||
function test_NotLike_Clause() {
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/opage.getOpageList.notlike.xml";
|
||||
$argsString = '$args->s_mid = "test";';
|
||||
$expected = 'select *
|
||||
from `xe_modules` as `modules`
|
||||
where `module` = \'opage\'
|
||||
and (`mid` not like \'%test%\')
|
||||
order by `module_srl` desc
|
||||
limit 0, 20';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
function test_NotLikeTail_Clause(){
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/opage.getOpageList.notliketail.xml";
|
||||
$argsString = '$args->s_mid = "test";';
|
||||
$expected = 'select *
|
||||
function test_NotLikeTail_Clause() {
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/opage.getOpageList.notliketail.xml";
|
||||
$argsString = '$args->s_mid = "test";';
|
||||
$expected = 'select *
|
||||
from `xe_modules` as `modules`
|
||||
where `module` = \'opage\'
|
||||
and (`mid` not like \'%test\')
|
||||
order by `module_srl` desc
|
||||
limit 0, 20';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
function test_NotLikePrefix_Clause(){
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/opage.getOpageList.notlikeprefix.xml";
|
||||
$argsString = '$args->s_mid = "test";';
|
||||
$expected = 'select *
|
||||
function test_NotLikePrefix_Clause() {
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/opage.getOpageList.notlikeprefix.xml";
|
||||
$argsString = '$args->s_mid = "test";';
|
||||
$expected = 'select *
|
||||
from `xe_modules` as `modules`
|
||||
where `module` = \'opage\'
|
||||
and (`mid` not like \'test%\')
|
||||
order by `module_srl` desc
|
||||
limit 0, 20';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
function test_WidgetsNewestDocument_getNewestDocuments(){
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/widgets.newest_document.getNewestDocuments.xml";
|
||||
$argsString = '$args->module_srl = "566036,3777868";';
|
||||
$expected = 'select `modules`.`site_srl` as `site_srl`
|
||||
function test_WidgetsNewestDocument_getNewestDocuments() {
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/widgets.newest_document.getNewestDocuments.xml";
|
||||
$argsString = '$args->module_srl = "566036,3777868";';
|
||||
$expected = 'select `modules`.`site_srl` as `site_srl`
|
||||
, `modules`.`mid` as `mid`
|
||||
, `documents`.*
|
||||
from `xe_modules` as `modules`
|
||||
|
|
@ -205,13 +205,13 @@
|
|||
and `documents`.`list_order` <= 2100000000
|
||||
order by `documents`.`list_order` asc
|
||||
limit 20';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
function test_homepage_getNewestComments(){
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/homepage.getNewestComments.xml";
|
||||
$argsString = ';';
|
||||
$expected = 'select `sites`.`domain` as `domain`
|
||||
function test_homepage_getNewestComments() {
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/homepage.getNewestComments.xml";
|
||||
$argsString = ';';
|
||||
$expected = 'select `sites`.`domain` as `domain`
|
||||
, `comments`.*
|
||||
from `xe_homepages` as `homepages`
|
||||
, `xe_sites` as `sites`
|
||||
|
|
@ -227,17 +227,37 @@
|
|||
and `module_grants`.`group_srl` is null)
|
||||
and `comments`.`list_order` <= 2100000000
|
||||
order by `comments`.`list_order` asc limit 0, 5';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
function test_distinct_outer_join(){
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/distinct_outer_join.xml";
|
||||
$argsString = '$args->site_srl = 0;';
|
||||
$expected = 'select distinct `modules`.`module_srl` as `module_site_srl`
|
||||
function test_distinct_outer_join() {
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/distinct_outer_join.xml";
|
||||
$argsString = '$args->site_srl = 0;';
|
||||
$expected = 'select distinct `modules`.`module_srl` as `module_site_srl`
|
||||
from `xe_sites` as `sites`
|
||||
left join `xe_modules` as `modules` on `modules`.`module_srl` = `sites`.`index_module_srl`
|
||||
where `sites`.`site_srl` = 0';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
}
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
function test_getDocumentListWithinComment() {
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/document.getDocumentListWithinComment.xml";
|
||||
$argsString = '$args->module_srl = 19778968;
|
||||
$args->s_comment = "dfsds";
|
||||
$args->statusList = "PUBLIC, SECRET";
|
||||
';
|
||||
$expected = 'select `documents`.`document_srl`, `documents`.`list_order`
|
||||
from `xe_documents` as `documents`
|
||||
, `xe_comments` as `comments`
|
||||
where (`documents`.`module_srl` in (19778968)
|
||||
and `documents`.`document_srl` = `comments`.`document_srl`
|
||||
and `documents`.`status` in (\'public\',\'secret\')
|
||||
and `comments`.`content` like \'%dfsds%\')
|
||||
and comments.list_order <= 2100000000
|
||||
group by `documents`.`document_srl`
|
||||
order by `comments`.`list_order` asc
|
||||
limit 0, 20';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<query id="getDocumentListWithinComment" action="select">
|
||||
<tables>
|
||||
<table name="documents" alias="documents" />
|
||||
<table name="comments" alias="comments" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="documents.document_srl" />
|
||||
<column name="documents.list_order" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="in" column="documents.module_srl" var="module_srl" filter="number" />
|
||||
<condition operation="notin" column="documents.module_srl" var="exclude_module_srl" filter="number" pipe="and" />
|
||||
<condition operation="equal" column="documents.category_srl" var="category_srl" pipe="and" />
|
||||
<condition operation="equal" column="documents.document_srl" default="comments.document_srl" notnull="notnull" pipe="and" />
|
||||
<condition operation="equal" column="documents.member_srl" var="member_srl" filter="number" pipe="and" />
|
||||
<condition operation="in" column="documents.status" var="statusList" pipe="and" />
|
||||
<group pipe="and">
|
||||
<condition operation="more" column="documents.list_order" var="division" pipe="and" />
|
||||
<condition operation="below" column="documents.list_order" var="last_division" pipe="and" />
|
||||
</group>
|
||||
<condition operation="like" column="comments.content" var="s_comment" notnull="notnull" pipe="and" />
|
||||
</conditions>
|
||||
<navigation>
|
||||
<index var="sort_index" default="comments.list_order" order="asc" />
|
||||
<list_count var="list_count" default="20" />
|
||||
<page_count var="page_count" default="10" />
|
||||
<page var="page" default="1" />
|
||||
</navigation>
|
||||
<groups>
|
||||
<group column="documents.document_srl" />
|
||||
</groups>
|
||||
</query>
|
||||
Loading…
Add table
Add a link
Reference in a new issue