From: Ash Berlin Date: Mon, 2 Mar 2009 00:30:21 +0000 (+0000) Subject: Fix typo in tests X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7d3908d35213638d237080ef4c06afb99822ac08;p=dbsrgits%2FSQL-Abstract-2.0-ish.git Fix typo in tests --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 4e7fcb8..3c84192 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -114,12 +114,10 @@ class SQL::Abstract { method _where(ArrayRef $ast) { my (undef, @clauses) = @$ast; - $DB::single = 1; return 'WHERE ' . $self->_recurse_where(\@clauses); } method _recurse_where($clauses) { - $DB::single = 1; my $OP = 'AND'; my $prio = $PRIO{and}; @@ -133,6 +131,7 @@ class SQL::Abstract { my @output; foreach (@$clauses) { + croak "invalid component in where clause" unless ArrayRef->check($_); my $op = $_->[0]; unless (substr($op, 0, 1) eq '-') { diff --git a/t/001_basic.t b/t/001_basic.t index 0ad697f..1322dbc 100644 --- a/t/001_basic.t +++ b/t/001_basic.t @@ -5,7 +5,6 @@ use Test::More tests => 9; use_ok('SQL::Abstract') or BAIL_OUT( "$@" ); - $DB::single = 1; is SQL::Abstract->generate( [ -name => qw/me id/]), "me.id", "Simple name generator"; @@ -25,43 +24,43 @@ is SQL::Abstract->generate( is SQL::Abstract->generate( [ -where => - [ '>', [-name => qw/me.id/], [-value => 500 ] ] + [ '>', [-name => qw/me id/], [-value => 500 ] ] ] ), "WHERE me.id > ?", "where clause"; is SQL::Abstract->generate( [ -where => - [ '>', [-name => qw/me.id/], [-value => 500 ] ], - [ '==', [-name => qw/me.name/], [-value => '200' ] ] + [ '>', [-name => qw/me id/], [-value => 500 ] ], + [ '==', [-name => qw/me name/], [-value => '200' ] ] ] ), "WHERE me.id > ? AND me.name = ?", "where clause"; is SQL::Abstract->generate( [ -where => -or => - [ '>', [-name => qw/me.id/], [-value => 500 ] ], - [ '==', [-name => qw/me.name/], [-value => '200' ] ], + [ '>', [-name => qw/me id/], [-value => 500 ] ], + [ '==', [-name => qw/me name/], [-value => '200' ] ], ] ), "WHERE me.id > ? OR me.name = ?", "where clause"; is SQL::Abstract->generate( [ -where => -or => - [ '>', [-name => qw/me.id/], [-value => 500 ] ], + [ '>', [-name => qw/me id/], [-value => 500 ] ], [ -or => - [ '==', [-name => qw/me.name/], [-value => '200' ] ], - [ '==', [-name => qw/me.name/], [-value => '100' ] ] + [ '==', [-name => qw/me name/], [-value => '200' ] ], + [ '==', [-name => qw/me name/], [-value => '100' ] ] ] ] ), "WHERE me.id > ? OR me.name = ? OR me.name = ?", "where clause"; is SQL::Abstract->generate( [ -where => -or => - [ '==', [-name => qw/me.id/], [-value => 500 ] ], + [ '==', [-name => qw/me id/], [-value => 500 ] ], [ -and => - [ '>', [-name => qw/me.name/], [-value => '200' ] ], - [ '<', [-name => qw/me.name/], [-value => '100' ] ] + [ '>', [-name => qw/me name/], [-value => '200' ] ], + [ '<', [-name => qw/me name/], [-value => '100' ] ] ] ] ), "WHERE me.id = ? OR (me.name > ? AND me.name < ?)", "where clause";