From: Ash Berlin Date: Wed, 15 Apr 2009 05:59:29 +0000 (-0700) Subject: Simple start on UPDATE clause backcompat X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FSQL-Abstract-2.0-ish.git;a=commitdiff_plain;h=73e799a6702cd272253307216d5ee99b1babba20 Simple start on UPDATE clause backcompat --- diff --git a/lib/SQL/Abstract/Compat.pm b/lib/SQL/Abstract/Compat.pm index edde9e7..2ba75f8 100644 --- a/lib/SQL/Abstract/Compat.pm +++ b/lib/SQL/Abstract/Compat.pm @@ -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 index 0000000..d55e7fd --- /dev/null +++ b/t/compat/ast/02update.t @@ -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"; + + +