From: Ash Berlin Date: Fri, 1 May 2009 21:28:45 +0000 (+0100) Subject: Simple work on update errors X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=99124578a32886518e61f7a34c0d86549564d42b;p=dbsrgits%2FSQL-Abstract-2.0-ish.git Simple work on update errors --- diff --git a/lib/SQL/Abstract/AST/v1.pm b/lib/SQL/Abstract/AST/v1.pm index 1d49094..604c02a 100644 --- a/lib/SQL/Abstract/AST/v1.pm +++ b/lib/SQL/Abstract/AST/v1.pm @@ -97,10 +97,9 @@ class SQL::Abstract::AST::v1 extends SQL::Abstract { 'SET' ); - confess 'update: number of columns doesn\'t match values: ' . dump($ast) + confess 'update: Number of values does not match columns: ' . dump($ast) if @{$ast->{columns}} != @{$ast->{values}}; - $DB::single = 1; my $list = { -type => 'list', args => [ map { diff --git a/lib/SQL/Abstract/Compat.pm b/lib/SQL/Abstract/Compat.pm index 2ba75f8..af08032 100644 --- a/lib/SQL/Abstract/Compat.pm +++ b/lib/SQL/Abstract/Compat.pm @@ -86,7 +86,7 @@ class SQL::Abstract::Compat { method update(Str|ArrayRef|ScalarRef $from, HashRef $fields, WhereType $where? ) { - my $ast = $self->update_aste($from,$fields,$where); + my $ast = $self->update_ast($from,$fields,$where); return ($self->visitor->dispatch($ast), @{$self->visitor->binds}); } diff --git a/t/900_errors.t b/t/900_errors.t index b86eda0..285618b 100644 --- a/t/900_errors.t +++ b/t/900_errors.t @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 6; +use Test::More tests => 7; use Test::Exception; use FindBin; @@ -60,4 +60,19 @@ throws_ok { ] } ) -} qr/^'values' is required in update AST/, "Invalid clause in update" +} qr/^'values' is required in update AST/, "Invalid clause in update"; + + +throws_ok { $sqla->dispatch( + { -type => 'update', + tablespec => mk_name('test'), + columns => [ + mk_name(qw/me id/), + mk_name(qw/hostname/), + ], + values => [ + mk_value('localhost'), + ] + } ) +} qr/Number of values does not match columns/, + "Column/values count mismatch in update";