[Jifty-commit] r6316 - Jifty-DBI/branches/tisql-joins-refactoring/lib/Jifty/DBI

Jifty commits jifty-commit at lists.jifty.org
Thu Feb 5 18:21:38 EST 2009


Author: ruz
Date: Thu Feb  5 18:21:38 2009
New Revision: 6316

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

Log:
* fix bindings

Modified: Jifty-DBI/branches/tisql-joins-refactoring/lib/Jifty/DBI/Tisql.pm
==============================================================================
--- Jifty-DBI/branches/tisql-joins-refactoring/lib/Jifty/DBI/Tisql.pm	(original)
+++ Jifty-DBI/branches/tisql-joins-refactoring/lib/Jifty/DBI/Tisql.pm	Thu Feb  5 18:21:38 2009
@@ -101,7 +101,7 @@
 
     my $tree = {};
 
-    $self->{'bindings'} = \@binds;
+    local $self->{'bindings'} = \@binds;
     $tree->{'conditions'} = $parser->as_array(
         $string, operand_cb => sub {
             return $self->parse_condition( 
@@ -110,7 +110,6 @@
         },
     );
 
-    $self->{'bindings'} = undef;
     $self->{'tisql'}{'conditions'} = $tree->{'conditions'};
     $self->apply_query_tree( $tree->{'conditions'} );
     return $self;
@@ -213,12 +212,15 @@
             $limit{'value'} =
                 $self->resolve_join( $condition->{'rhs'} )
                 .'.'. $condition->{'rhs'}{'chain'}[-1]{'name'};
+        } elsif ( ref $condition->{'rhs'} eq 'ARRAY' ) {
+            $parser->dq( $_ ) foreach @{ $condition->{'rhs'} };
+            $limit{'value'} = $condition->{'rhs'};
+        } elsif ( $condition->{'rhs'} eq '?' ) {
+            die "Not enough binding values provided for the query"
+                unless @{ $self->{'bindings'} };
+            $limit{'value'} = shift @{ $self->{'bindings'} };
         } else {
-            if ( ref $condition->{'rhs'} eq 'ARRAY' ) {
-                $parser->dq( $_ ) foreach @{ $condition->{'rhs'} };
-            } else {
-                $parser->dq( $condition->{'rhs'} );
-            }
+            $parser->dq( $condition->{'rhs'} );
             $limit{'value'} = $condition->{'rhs'};
         }
 


More information about the Jifty-commit mailing list