mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 11:11:39 +09:00
Issue 1023 - Bug when paging query with outer join and distinct.
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10299 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
fef0e92afd
commit
ad88ec5f8c
4 changed files with 38 additions and 1 deletions
|
|
@ -467,7 +467,16 @@
|
|||
// Total count
|
||||
$temp_where = $queryObject->getWhereString(true, false);
|
||||
$count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString(), ($temp_where === '' ? '' : ' WHERE '. $temp_where));
|
||||
if ($queryObject->getGroupByString() != '') {
|
||||
|
||||
// Check for distinct query and if found update count query structure
|
||||
$temp_select = $queryObject->getSelectString();
|
||||
if(strpos(strtolower($temp_select), "distinct") !== false) {
|
||||
$count_query = sprintf('select %s %s %s', 'FROM ' . $queryObject->getFromString(), $temp_select, ($temp_where === '' ? '' : ' WHERE '. $temp_where));
|
||||
$uses_distinct = true;
|
||||
}
|
||||
|
||||
// If query uses grouping or distinct, count from original select
|
||||
if ($queryObject->getGroupByString() != '' || $uses_distinct) {
|
||||
$count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@
|
|||
if($this->isStarFunction($column_name)){
|
||||
return $column_name;
|
||||
}
|
||||
if(strpos(strtolower($column_name), 'distinct') !== false) return $column_name;
|
||||
return $this->escapeColumn($column_name);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -229,4 +229,15 @@
|
|||
order by `comments`.`list_order` asc limit 0, 5';
|
||||
$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`
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<query id="getSiteInfo" action="select">
|
||||
<tables>
|
||||
<table name="sites" alias="sites" />
|
||||
<table name="modules" alias="modules" type="left join">
|
||||
<conditions>
|
||||
<condition operation="equal" column="modules.module_srl" default="sites.index_module_srl" notnull="notnull" pipe="and" />
|
||||
</conditions>
|
||||
</table>
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="DISTINCT modules.module_srl" alias="module_site_srl" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="sites.site_srl" var="site_srl" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
Loading…
Add table
Add a link
Reference in a new issue