Simple start on UPDATE clause backcompat
Ash Berlin [Wed, 15 Apr 2009 05:59:29 +0000 (22:59 -0700)]
lib/SQL/Abstract/Compat.pm
t/compat/ast/02update.t [new file with mode: 0644]

index edde9e7..2ba75f8 100644 (file)
@@ -80,10 +80,23 @@ class SQL::Abstract::Compat {
   {
     my $ast = $self->select_ast($from,$fields,$where,$order);
 
-    $DB::single = 1;
     return ($self->visitor->dispatch($ast), @{$self->visitor->binds});
   }
 
+  method update(Str|ArrayRef|ScalarRef $from,   
+                HashRef $fields, WhereType $where? )
+  {
+    my $ast = $self->update_aste($from,$fields,$where);
+
+    return ($self->visitor->dispatch($ast), @{$self->visitor->binds});
+  }
+
+  method update_ast(Str|ArrayRef|ScalarRef $from,   
+                    HashRef $fields, WhereType $where? ) 
+  {
+    return { -type => 'update' };
+  }
+
   method select_ast(Str|ArrayRef|ScalarRef $from, ArrayRef|Str $fields,
                 WhereType $where?,
                 WhereType $order?)
diff --git a/t/compat/ast/02update.t b/t/compat/ast/02update.t
new file mode 100644 (file)
index 0000000..d55e7fd
--- /dev/null
@@ -0,0 +1,38 @@
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/../../lib";
+use Test::SQL::Abstract::Util qw/
+  mk_name
+  mk_value
+  mk_expr
+  field_op_value
+  :dumper_sort
+/;
+
+use SQL::Abstract::Compat;
+
+use Test::More tests => 2;
+use Test::Differences;
+
+ok(my $visitor = SQL::Abstract::Compat->new);
+
+
+my $foo_id = { -type => 'identifier', elements => [qw/foo/] };
+my $bar_id = { -type => 'identifier', elements => [qw/bar/] };
+
+my $foo_eq_1 = field_op_value($foo_id, '==', 1);
+my $bar_eq_str = field_op_value($bar_id, '==', 'some str');
+
+local $TODO = 'Work out what this should be';
+eq_or_diff
+  $visitor->update_ast('test', { foo => 1 }),
+  { -type => 'update',
+    tablespec => mk_name('test'),
+
+  },
+  "simple update";
+
+
+