[Jifty-commit] r7337 - in Jifty-DBI/branches/tisql: lib/Jifty/DBI

Jifty commits jifty-commit at lists.jifty.org
Sat Jul 18 08:34:43 EDT 2009


Author: ruz
Date: Sat Jul 18 08:34:43 2009
New Revision: 7337

Modified:
   Jifty-DBI/branches/tisql/   (props changed)
   Jifty-DBI/branches/tisql/lib/Jifty/DBI/Tisql.pm

Log:
 r7308 at Macintosh:  ruz | 2009-06-22 03:50:04 +0300
 * implement clone in the query tree


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	Sat Jul 18 08:34:43 2009
@@ -133,7 +133,9 @@
 
 sub query_struct {
     my $self = shift;
+
     my $tree = shift;
+    $tree = $tree->clone;
 
     $self->{'tisql'}{'conditions'} = [ $tree->isa('HASH')? $tree : @$tree ]; #xxx: hack :)
     $self->apply_query_tree( $self->{'tisql'}{'conditions'} );
@@ -738,6 +740,22 @@
     return $self;
 }
 
+sub clone {
+    my $self = shift;
+
+    require Storable;
+
+    my %new = %$self;
+    foreach (qw(lhs rhs)) {
+        if ( blessed $new{$_} ) {
+            $new{$_} = $new{$_}->clone;
+        } else {
+            $new{$_} = Storable::dclone( $new{$_} );
+        }
+    }
+    return $self->new( %new );
+}
+
 sub parse {
     my ($self, $type, $string, $cb) = @_;
 


More information about the Jifty-commit mailing list