mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-20 19:59:54 +09:00
Updates to unit tests for correlated subqueries.
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8560 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
e313076cc8
commit
909276e16b
8 changed files with 54 additions and 55 deletions
|
|
@ -86,23 +86,30 @@
|
|||
function testWhereCorrelated1(){
|
||||
$xml_file = $this->xmlPath . "where_correlated1.xml";
|
||||
$argsString = '';
|
||||
$expected = ' SELECT *
|
||||
FROM xe_member as member
|
||||
WHERE regdate = (SELECT MAX(regdate) as regdate
|
||||
FROM xe_documents as documents
|
||||
WHERE documents.user_id = member.user_id)';
|
||||
$expected = 'select *
|
||||
from "xe_member" as "member"
|
||||
where "regdate" = (
|
||||
select max("regdate") as "maxregdate"
|
||||
from "xe_documents" as "documents"
|
||||
where "documents"."user_id" = "member"."user_id"
|
||||
)';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
function testFromCorrelated1(){
|
||||
$xml_file = $this->xmlPath . "from_correlated1.xml";
|
||||
$argsString = '';
|
||||
$expected = 'SELECT m.member_srl, m.nickname, m.regdate, a.count
|
||||
FROM (
|
||||
SELECT documents.member_srl as member_srl, count(*) as count
|
||||
FROM xe_documents as documents
|
||||
GROUP BY documents.member_srl) a
|
||||
INNER JOIN xe_members m on m.member_srl = a.member_srl';
|
||||
$expected = 'select "m"."member_srl"
|
||||
, "m"."nickname"
|
||||
, "m"."regdate"
|
||||
, "a"."count"
|
||||
from (
|
||||
select "member_srl" as "member_srl"
|
||||
, count(*) as "count"
|
||||
from "xe_documents" as "documents"
|
||||
group by "member_srl"
|
||||
) as "a"
|
||||
left join "xe_member" as "m" on "m"."member" = "a"."member_srl"';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<query id="getMemberInfo" action="select">
|
||||
<tables>
|
||||
<query alias="a">
|
||||
<table query="true" alias="a">
|
||||
<tables>
|
||||
<table name="documents" alias="documents" />
|
||||
</tables>
|
||||
|
|
@ -11,8 +11,8 @@
|
|||
<groups>
|
||||
<group column="member_srl" />
|
||||
</groups>
|
||||
</query>
|
||||
<table name="member" alias="m" type="inner join">
|
||||
</table>
|
||||
<table name="member" alias="m" type="left join">
|
||||
<conditions>
|
||||
<condition operation="equal" column="m.member" default="a.member_srl" />
|
||||
</conditions>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<query id="getMemberInfo" action="select">
|
||||
<tables>
|
||||
<query alias="documentCountByMember">
|
||||
<table query="true" alias="documentCountByMember">
|
||||
<tables>
|
||||
<table name="documents" alias="documents" />
|
||||
</tables>
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
<groups>
|
||||
<group column="member_srl" />
|
||||
</groups>
|
||||
</query>
|
||||
</table>
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="MAX(documentCountByMember.count)" alias="maxCount" />
|
||||
|
|
|
|||
|
|
@ -6,17 +6,16 @@
|
|||
<column name="*" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<query id="getDocumentMaxRegdate" alias="documentMaxRegdate" operation="equal" column="regdate" notnull="notnull">
|
||||
<tables>
|
||||
<table name="documents" alias="documents" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="max(regdate)" alias="maxregdate" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="documents.user_id" var="member.user_id" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
</condition>
|
||||
<query alias="documentMaxRegdate" operation="equal" column="regdate" notnull="notnull">
|
||||
<tables>
|
||||
<table name="documents" alias="documents" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="max(regdate)" alias="maxregdate" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="documents.user_id" default="member.user_id" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
</conditions>
|
||||
</query>
|
||||
Loading…
Add table
Add a link
Reference in a new issue