[Jifty-commit] r1137 - in Jifty-DBI/trunk: lib/Jifty/DBI/Handle

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Thu Jun 1 22:46:15 EDT 2006


Author: jesse
Date: Thu Jun  1 22:46:14 2006
New Revision: 1137

Modified:
   Jifty-DBI/trunk/   (props changed)
   Jifty-DBI/trunk/Changes
   Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Oracle.pm

Log:
 r12046 at pinglin:  jesse | 2006-06-01 22:43:03 -0400
 * Oracle fixes from Mark Gardner
 


Modified: Jifty-DBI/trunk/Changes
==============================================================================
--- Jifty-DBI/trunk/Changes	(original)
+++ Jifty-DBI/trunk/Changes	Thu Jun  1 22:46:14 2006
@@ -1,5 +1,8 @@
 Revision history for Perl extension Jifty::DBI.
 
+* Oracle fixes from Mark Gardner
+
+
 0.21 Wed May  3 14:14:41 EDT 2006
 
 * We no longer do a count when setting up a collection's pager object by default

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	Thu Jun  1 22:46:14 2006
@@ -27,12 +27,12 @@
     my $self = shift;
 
     my %args = (
-        Driver   => undef,
-        Database => undef,
-        User     => undef,
-        Password => undef,
-        SID      => undef,
-        Host     => undef,
+        driver   => undef,
+        database => undef,
+        user     => undef,
+        password => undef,
+        sid      => undef,
+        host     => undef,
         @_
     );
 
@@ -119,31 +119,31 @@
 sub build_dsn {
     my $self = shift;
     my %args = (
-        Driver     => undef,
-        Database   => undef,
-        Host       => undef,
-        Port       => undef,
-        SID        => undef,
-        RequireSSL => undef,
+        driver     => undef,
+        database   => undef,
+        host       => undef,
+        port       => undef,
+        sid        => undef,
+        requiressl => undef,
         @_
     );
 
-    my $dsn = "dbi:$args{'Driver'}:";
+    my $dsn = "dbi:$args{'driver'}:";
 
-    if (   defined $args{'Host'}
-        && $args{'Host'}
-        && defined $args{'SID'}
-        && $args{'SID'} )
+    if (   defined $args{'host'}
+        && $args{'host'}
+        && defined $args{'sid'}
+        && $args{'sid'} )
     {
-        $dsn .= "host=$args{'Host'};sid=$args{'SID'}";
+        $dsn .= "host=$args{'host'};sid=$args{'sid'}";
     } else {
-        $dsn .= "$args{'Database'}"
-            if ( defined $args{'Database'} && $args{'Database'} );
+        $dsn .= "$args{'database'}"
+            if ( defined $args{'database'} && $args{'database'} );
     }
-    $dsn .= ";port=$args{'Port'}"
-        if ( defined $args{'Port'} && $args{'Port'} );
+    $dsn .= ";port=$args{'port'}"
+        if ( defined $args{'port'} && $args{'port'} );
     $dsn .= ";requiressl=1"
-        if ( defined $args{'RequireSSL'} && $args{'RequireSSL'} );
+        if ( defined $args{'requiressl'} && $args{'requiressl'} );
 
     $self->{'dsn'} = $dsn;
 }
@@ -226,44 +226,36 @@
 =cut
 
 sub distinct_query {
-  my $self         = shift;
-  my $statementref = shift;
-  my $sb           = shift;
-  my $table        = $sb->Table;
-
-  # Wrapp select query in a subselect as Oracle doesn't allow
-  # DISTINCT against CLOB/BLOB column types.
-  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 main.* FROM ( SELECT DISTINCT main.id FROM $$statementref ) distinctquery, $table main WHERE (main.id = distinctquery.id) ";
-    $$statementref .= $sb->_group_clause;
-    $$statementref .= $sb->_order_clause;
-  }
+    my $self         = shift;
+    my $statementref = shift;
+    my $sb           = shift;
+    my $table        = $sb->Table;
+
+    # Wrapp select query in a subselect as Oracle doesn't allow
+    # DISTINCT against CLOB/BLOB column types.
+    if ( $sb->_order_clause =~ /(?<!main)\./ ) {
+
+        # 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 main.* FROM ( SELECT DISTINCT main.id FROM $$statementref ) distinctquery, $table main WHERE (main.id = distinctquery.id) ";
+        $$statementref .= $sb->_group_clause;
+        $$statementref .= $sb->_order_clause;
+    }
 }
 
 1;


More information about the Jifty-commit mailing list