mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-24 13:49:56 +09:00
Started unit tests for correlated subqueries - select, from, where.
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8557 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
1353ade0c2
commit
e313076cc8
7 changed files with 147 additions and 14 deletions
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
function testSelectUncorrelated1(){
|
||||
$xml_file = $this->xmlPath . "select_uncorrelated1.xml";
|
||||
echo $xml_file;
|
||||
$argsString = '$args->user_id = 4;
|
||||
';
|
||||
$expected = 'select "column_a" as "value_a"
|
||||
|
|
@ -32,7 +31,6 @@
|
|||
|
||||
function testSelectUncorrelated2(){
|
||||
$xml_file = $this->xmlPath . "select_uncorrelated2.xml";
|
||||
echo $xml_file;
|
||||
$argsString = '$args->user_id = 4;
|
||||
$args->user_name = 7;
|
||||
';
|
||||
|
|
@ -49,7 +47,6 @@
|
|||
|
||||
function testFromUncorrelated(){
|
||||
$xml_file = $this->xmlPath . "from_uncorrelated1.xml";
|
||||
echo $xml_file;
|
||||
$argsString = '$args->user_id = 4;
|
||||
$args->user_name = 7;
|
||||
';
|
||||
|
|
@ -65,13 +62,48 @@
|
|||
|
||||
function testWhereUncorrelated(){
|
||||
$xml_file = $this->xmlPath . "where_uncorrelated1.xml";
|
||||
echo $xml_file;
|
||||
$argsString = '';
|
||||
$expected = 'select * from
|
||||
"xe_member" as "member"
|
||||
where "regdate" = (select max("regdate") as "maxregdate"
|
||||
from "xe_documents" as "documents")';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
}
|
||||
|
||||
function testSelectCorrelated1(){
|
||||
$xml_file = $this->xmlPath . "select_correlated1.xml";
|
||||
$argsString = '$args->user_id = 7;';
|
||||
$expected = 'select *,
|
||||
(select count(*) as "count"
|
||||
from "xe_documents" as "documents"
|
||||
where "documents"."user_id" = "member"."user_id"
|
||||
) as "totaldocumentcount"
|
||||
from "xe_member" as "member"
|
||||
where "user_id" = \'7\'';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
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)';
|
||||
$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';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
27
test-phpUnit/db/xml_query/cubrid/data/from_correlated1.xml
Normal file
27
test-phpUnit/db/xml_query/cubrid/data/from_correlated1.xml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<query id="getMemberInfo" action="select">
|
||||
<tables>
|
||||
<query alias="a">
|
||||
<tables>
|
||||
<table name="documents" alias="documents" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="member_srl" alias="member_srl" />
|
||||
<column name="count(*)" alias="count" />
|
||||
</columns>
|
||||
<groups>
|
||||
<group column="member_srl" />
|
||||
</groups>
|
||||
</query>
|
||||
<table name="member" alias="m" type="inner join">
|
||||
<conditions>
|
||||
<condition operation="equal" column="m.member" default="a.member_srl" />
|
||||
</conditions>
|
||||
</table>
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="m.member_srl" />
|
||||
<column name="m.nickname" />
|
||||
<column name="m.regdate" />
|
||||
<column name="a.count" />
|
||||
</columns>
|
||||
</query>
|
||||
22
test-phpUnit/db/xml_query/cubrid/data/select_correlated1.xml
Normal file
22
test-phpUnit/db/xml_query/cubrid/data/select_correlated1.xml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<query id="getStatistics" action="select">
|
||||
<tables>
|
||||
<table name="member" alias="member" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="*" />
|
||||
<query id="getMemberDocumentCount" alias="totalDocumentCount">
|
||||
<tables>
|
||||
<table name="documents" alias="documents" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="count(*)" alias="count" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="documents.user_id" default="member.user_id" />
|
||||
</conditions>
|
||||
</query>
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="user_id" var="user_id" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
22
test-phpUnit/db/xml_query/cubrid/data/where_correlated1.xml
Normal file
22
test-phpUnit/db/xml_query/cubrid/data/where_correlated1.xml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<query id="getMemberInfo" action="select">
|
||||
<tables>
|
||||
<table name="member" alias="member" />
|
||||
</tables>
|
||||
<columns>
|
||||
<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>
|
||||
</conditions>
|
||||
</query>
|
||||
Loading…
Add table
Add a link
Reference in a new issue