[Bps-public-commit] dbix-searchbuilder branch, master, updated. d77dd287821520704bf5a99b2b60b8879e81eb8d
Ruslan Zakirov
ruz at bestpractical.com
Mon Mar 22 12:52:33 EDT 2010
The branch, master has been updated
via d77dd287821520704bf5a99b2b60b8879e81eb8d (commit)
from 71f530e5ae278846fcad0b0995b55d3d8a5c79db (commit)
Summary of changes:
SearchBuilder/Handle/Pg.pm | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
- Log -----------------------------------------------------------------
commit d77dd287821520704bf5a99b2b60b8879e81eb8d
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Mon Mar 22 19:43:26 2010 +0300
update code comment to make it clear why old approach didn't work
diff --git a/SearchBuilder/Handle/Pg.pm b/SearchBuilder/Handle/Pg.pm
index bbeb69a..5dec864 100755
--- a/SearchBuilder/Handle/Pg.pm
+++ b/SearchBuilder/Handle/Pg.pm
@@ -230,8 +230,13 @@ sub DistinctQuery {
return $self->SUPER::DistinctQuery( $statementref, $sb, @_ )
if $sb->_OrderClause !~ /(?<!main)\./;
- # If we are ordering by something not in 'main', we need to GROUP
- # BY and adjust the ORDER_BY accordingly
+ # "SELECT main.* FROM ( SELECT id FROM ... ORDER BY ... ) as dist,
+ # X main WHERE (main.id = dist.id);" doesn't work in some cases.
+ # It's hard to show with tests. Pg's optimizer can choose execution
+ # plan not guaranting order
+
+ # So if we are ordering by something that is not in 'main', the we GROUP
+ # BY all columns and adjust the ORDER_BY accordingly
local $sb->{group_by} = [ map {+{FIELD => $_}} $self->Fields($table) ];
local $sb->{'order_by'} = [
map {
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list