[Bps-public-commit] dbix-searchbuilder branch, master, updated. 1.56_03-9-gcd52b30

Ruslan Zakirov ruz at bestpractical.com
Thu Sep 16 22:20:10 EDT 2010


The branch, master has been updated
       via  cd52b30a55fbc925620789a860ebfab66c794549 (commit)
       via  6cc8a8620437550fe6d4f0affbce9c76f98b7661 (commit)
      from  cf6f0c878cc813a11a183eb2f0a9020d544d7105 (commit)

Summary of changes:
 SearchBuilder.pm        |   14 +++++++++++---
 SearchBuilder/Handle.pm |    8 +++++---
 2 files changed, 16 insertions(+), 6 deletions(-)

- Log -----------------------------------------------------------------
commit 6cc8a8620437550fe6d4f0affbce9c76f98b7661
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Sep 17 06:08:23 2010 +0400

    allow join to depend on nothing

diff --git a/SearchBuilder/Handle.pm b/SearchBuilder/Handle.pm
index cd264f2..89dbae5 100755
--- a/SearchBuilder/Handle.pm
+++ b/SearchBuilder/Handle.pm
@@ -1088,9 +1088,11 @@ sub _BuildJoins {
 
     # get a @list of joins that have not been processed yet, but depend on processed join
     my $joins = $sb->{'left_joins'};
-    while ( my @list = grep !$processed{ $_ }
-            && $processed{ $joins->{ $_ }{'depends_on'} }, keys %$joins )
-    {
+    while ( my @list =
+        grep !$processed{ $_ }
+            && (!$joins->{ $_ }{'depends_on'} || $processed{ $joins->{ $_ }{'depends_on'} }),
+        keys %$joins
+    ) {
         foreach my $join ( @list ) {
             $processed{ $join }++;
 

commit cd52b30a55fbc925620789a860ebfab66c794549
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Sep 17 06:09:09 2010 +0400

    support $sb->NewAlias( 'table' => 'LEFT' );

diff --git a/SearchBuilder.pm b/SearchBuilder.pm
index 8fb055e..a1b1181 100755
--- a/SearchBuilder.pm
+++ b/SearchBuilder.pm
@@ -1137,12 +1137,20 @@ or to Limit what gets found by a search.
 sub NewAlias {
     my $self  = shift;
     my $table = shift || die "Missing parameter";
+    my $type = shift;
 
     my $alias = $self->_GetAlias($table);
 
-    my $subclause = "$table $alias";
-
-    push ( @{ $self->{'aliases'} }, $subclause );
+    unless ( $type ) {
+        push @{ $self->{'aliases'} }, "$table $alias";
+    } elsif ( lc $type eq 'left' ) {
+        my $meta = $self->{'left_joins'}{"$alias"} ||= {};
+        $meta->{'alias_string'} = " LEFT JOIN $table $alias ";
+        $meta->{'type'} = 'LEFT';
+        $meta->{'depends_on'} = '';
+    } else {
+        die "Unsupported alias(join) type";
+    }
 
     return $alias;
 }

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list