[Rt-commit] r4047 - in Jifty-DBI/trunk: . lib/Jifty/DBI

jesse at bestpractical.com jesse at bestpractical.com
Mon Nov 7 01:24:54 EST 2005


Author: jesse
Date: Mon Nov  7 01:24:54 2005
New Revision: 4047

Modified:
   Jifty-DBI/trunk/   (props changed)
   Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm
   Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm
Log:
 r18438 at truegrounds:  jesse | 2005-11-07 01:22:44 -0500
  * cleanups to left_join query building ; allowed entry_aggregators for left_join criteria


Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm	Mon Nov  7 01:24:54 2005
@@ -1122,7 +1122,7 @@
 table for the second field rather than merely an alias.  For this type
 of join, it will return the alias generated by the join.
 
-Instead of alias1/column1, it's possible to specify EXPRESSION, to join
+Instead of alias1/column1, it's possible to specify expression, to join
 alias2/table2 on an arbitrary expression.
 
 =cut

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm	Mon Nov  7 01:24:54 2005
@@ -768,7 +768,7 @@
         table2     => undef,
         column2    => undef,
         alias2     => undef,
-        EXPRESSION => undef,
+        expression => undef,
         @_
     );
 
@@ -847,14 +847,16 @@
     }
 
     my $criterion;
-    if ( $args{'EXPRESSION'} ) {
-        $criterion = $args{'EXPRESSION'};
+    if ( $args{'expression'} ) {
+        $criterion = $args{'expression'};
     }
     else {
         $criterion = $args{'alias1'} . "." . $args{'column1'};
     }
 
     $args{'collection'}->{'leftjoins'}{"$alias"}{'alias_string'} = $string;
+    $args{'collection'}->{'leftjoins'}{"$alias"}{'entry_aggregator'}
+          = $args{'entry_aggregator'} if ( $args{'entry_aggregator'} );
     $args{'collection'}->{'leftjoins'}{"$alias"}{'depends_on'}
         = $args{'alias1'};
     $args{'collection'}->{'leftjoins'}{"$alias"}{'criteria'}
@@ -929,12 +931,15 @@
         if ( !$sb->{'leftjoins'}{$join}{'depends_on'}
             || $seen_aliases{ $sb->{'leftjoins'}{$join}{'depends_on'} } )
         {
-            $join_clause = "(" . $join_clause;
-            $join_clause
-                .= $sb->{'leftjoins'}{$join}{'alias_string'} . " ON (";
-            $join_clause .= CORE::join( ') AND( ',
-                values %{ $sb->{'leftjoins'}{$join}{'criteria'} } );
-            $join_clause .= ")) ";
+            $join_clause .= $sb->{'leftjoins'}{$join}{'alias_string'} . " ON ";
+          
+            my @criteria = values %{ $sb->{'leftjoins'}{$join}{'criteria'} } ;
+            my $entry_aggregator =  $sb->{'leftjoins'}{$join}{'entry_aggregator'}  || 'AND';
+            my $criteria = CORE::join( " $entry_aggregator ", map { " ( $_ ) " } @criteria);  
+
+            $join_clause .= "( ".$criteria. " ) ";
+            $join_clause = "(" .$join_clause .")";
+
 
             $seen_aliases{$join} = 1;
         }


More information about the Rt-commit mailing list