[Jifty-commit] r980 - in Jifty-DBI/trunk: lib/Jifty/DBI/Handle
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Wed May 3 16:33:57 EDT 2006
Author: jesse
Date: Wed May 3 16:33:56 2006
New Revision: 980
Modified:
Jifty-DBI/trunk/ (props changed)
Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Oracle.pm
Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Pg.pm
Log:
r13188 at hualien: jesse | 2006-05-03 16:33:25 -0400
* Logic errror in that previous commit
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Oracle.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Oracle.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Oracle.pm Wed May 3 16:33:56 2006
@@ -233,10 +233,15 @@
# Wrapp select query in a subselect as Oracle doesn't allow
# DISTINCT against CLOB/BLOB column types.
- if ( grep { $_->{'alias'} ne 'main' || defined $_->{'function'} }
- @{ $sb->order_by } )
+ if (
+ grep {
+ ( defined $_->{'alias'} and $_->{'alias'} ne 'main' )
+ || defined $_->{'function'}
+ } @{ $sb->order_by }
+ )
{
+
# If we are ordering by something not in 'main', we need to GROUP
# BY and adjust the ORDER_BY accordingly
local $sb->{group_by}
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Pg.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Pg.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Pg.pm Wed May 3 16:33:56 2006
@@ -194,35 +194,40 @@
=cut
sub distinct_query {
- my $self = shift;
- my $statementref = shift;
- my $sb = shift;
- my $table = $sb->table;
-
- if ( grep { $_->{'alias'} ne 'main'
- || defined $_->{'function'} }
- @{ $sb->order_by } ) {
-
- # If we are ordering by something not in 'main', we need to GROUP
- # BY and adjust the ORDER_BY accordingly
- local $sb->{group_by}
- = [ @{ $sb->{group_by} || [] }, { column => 'id' } ];
- local $sb->{order_by} = [
- map {
- ( $_->{alias} and $_->{alias} ne "main" )
- ? { %{$_}, column => "min(" . $_->{column} . ")" }
- : $_
- } @{ $sb->{order_by} }
- ];
- my $group = $sb->_group_clause;
- my $order = $sb->_order_clause;
- $$statementref
- = "SELECT main.* FROM ( SELECT main.id FROM $$statementref $group $order ) distinctquery, $table main WHERE (main.id = distinctquery.id)";
- } else {
- $$statementref = "SELECT DISTINCT main.* FROM $$statementref";
- $$statementref .= $sb->_group_clause;
- $$statementref .= $sb->_order_clause;
- }
+ my $self = shift;
+ my $statementref = shift;
+ my $sb = shift;
+ my $table = $sb->table;
+
+ if (
+ grep {
+ ( defined $_->{'alias'} and $_->{'alias'} ne 'main' )
+ || defined $_->{'function'}
+ } @{ $sb->order_by }
+ )
+ {
+
+ # If we are ordering by something not in 'main', we need to GROUP
+ # BY and adjust the ORDER_BY accordingly
+ local $sb->{group_by}
+ = [ @{ $sb->{group_by} || [] }, { column => 'id' } ];
+ local $sb->{order_by} = [
+ map {
+ ( $_->{alias} and $_->{alias} ne "main" )
+ ? { %{$_}, column => "min(" . $_->{column} . ")" }
+ : $_
+ } @{ $sb->{order_by} }
+ ];
+ my $group = $sb->_group_clause;
+ my $order = $sb->_order_clause;
+ $$statementref
+ = "SELECT main.* FROM ( SELECT main.id FROM $$statementref $group $order ) distinctquery, $table main WHERE (main.id = distinctquery.id)";
+ }
+ else {
+ $$statementref = "SELECT DISTINCT main.* FROM $$statementref";
+ $$statementref .= $sb->_group_clause;
+ $$statementref .= $sb->_order_clause;
+ }
}
1;
More information about the Jifty-commit
mailing list