[Jifty-commit] r6273 - Jifty-DBI/branches/tisql/lib/Jifty/DBI

Jifty commits jifty-commit at lists.jifty.org
Mon Jan 26 04:50:32 EST 2009


Author: ruz
Date: Mon Jan 26 04:50:32 2009
New Revision: 6273

Modified:
   Jifty-DBI/branches/tisql/lib/Jifty/DBI/Tisql.pm

Log:
* use filter from Parse::BooleanLogic

Modified: Jifty-DBI/branches/tisql/lib/Jifty/DBI/Tisql.pm
==============================================================================
--- Jifty-DBI/branches/tisql/lib/Jifty/DBI/Tisql.pm	(original)
+++ Jifty-DBI/branches/tisql/lib/Jifty/DBI/Tisql.pm	Mon Jan 26 04:50:32 2009
@@ -330,7 +330,9 @@
         ) },
     );
 
-    $tree = $self->filter_conditions_tree( $tree, sub {
+
+    # fill in placeholders
+    $tree = $parser->filter( $tree, sub {
         my $rhs = $_[0]->{'rhs'};
         if ( $rhs && !ref $rhs && $rhs =~ /^%([0-9]+)$/ ) {
             return 0 unless defined $meta->{'placeholders'}[ $1 - 1 ];
@@ -349,7 +351,7 @@
                     }
                 }
                 $tmp = $tmp->{previous};
-            };
+            }
         }
         return 1;
     } );
@@ -501,38 +503,6 @@
     return $last;
 }
 
-sub filter_conditions_tree {
-    my ($self, $tree, $cb, $inner) = @_;
-
-    my $skip_next = 0;
-
-    my @res;
-    foreach my $entry ( @$tree ) {
-        next if $skip_next-- > 0;
-
-        if ( ref $entry eq 'ARRAY' ) {
-            my $tmp = $self->filter_conditions_tree( $entry, $cb, 1 );
-            if ( !$tmp || (ref $tmp eq 'ARRAY' && !@$tmp) ) {
-                pop @res;
-                $skip_next = 1 unless @res;
-            } else {
-                push @res, $tmp;
-            }
-        } elsif ( ref $entry eq 'HASH' ) {
-            if ( $cb->( $entry ) ) {
-                push @res, $entry;
-            } else {
-                pop @res;
-                $skip_next = 1 unless @res;
-            }
-        } else {
-            push @res, $entry;
-        }
-    }
-    return $res[0] if @res == 1 && ($inner || ref $res[0] eq 'ARRAY');
-    return \@res;
-}
-
 sub apply_callback_to_tree {
     my ($self, $tree, $cb) = @_;
 


More information about the Jifty-commit mailing list