From: Matt S Trout Date: Tue, 2 Aug 2011 12:11:24 +0000 (+0000) Subject: handle scalarref in arrayref of table names X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7732c37a;p=dbsrgits%2FSQL-Abstract.git handle scalarref in arrayref of table names --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 632b15c..2a878f7 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -747,11 +747,11 @@ sub _table_to_dq { my ($self, $from) = @_; if (ref($from) eq 'ARRAY') { die "Empty FROM list" unless my @f = @$from; - my $dq = $self->_ident_to_dq(shift @f); + my $dq = $self->_table_to_dq(shift @f); while (my $x = shift @f) { $dq = { type => DQ_JOIN, - join => [ $dq, $self->_ident_to_dq($x) ] + join => [ $dq, $self->_table_to_dq($x) ] }; } $dq; diff --git a/t/01generate.t b/t/01generate.t index 1f305bb..a32fbe6 100644 --- a/t/01generate.t +++ b/t/01generate.t @@ -78,6 +78,13 @@ my @tests = ( }, { func => 'select', + args => [[\'test1', 'test2'], '*', { 'test1.a' => { 'In', ['boom', 'bang'] } }], + stmt => 'SELECT * FROM test1, test2 WHERE ( test1.a IN ( ?, ? ) )', + stmt_q => 'SELECT * FROM test1, `test2` WHERE ( `test1`.`a` IN ( ?, ? ) )', + bind => ['boom', 'bang'] + }, + { + func => 'select', args => ['test', '*', { a => { 'between', ['boom', 'bang'] } }], stmt => 'SELECT * FROM test WHERE ( a BETWEEN ? AND ? )', stmt_q => 'SELECT * FROM `test` WHERE ( `a` BETWEEN ? AND ? )',