From: Matt S Trout Date: Sat, 16 Oct 2010 02:05:27 +0000 (+0100) Subject: test AS export X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a0ab336b4a910f8a6254816e3b218815c9319b56;p=dbsrgits%2FData-Query.git test AS export --- diff --git a/t/expr.include b/t/expr.include index 0521b29..fe18512 100644 --- a/t/expr.include +++ b/t/expr.include @@ -33,9 +33,9 @@ sub SELECT (&;@) { my @final; while (@select) { my $e = shift @select; - my $res = push @final, +{ expr => $e->{expr} }; + push @final, my $res = { expr => $e->{expr} }; if (ref($select[0]) eq 'LIES::AS') { - $res->{name} = identifier(shift @select); + $res->{name} = identifier(${shift @select}); } } diff --git a/t/sql.t b/t/sql.t index adac5af..f0e0d8a 100644 --- a/t/sql.t +++ b/t/sql.t @@ -56,3 +56,11 @@ expr_sql_is { SELECT { $_->foo, 1 } } # will need rewriting to fix it - commit bits available if you do it first [ "SELECT foo , ?", binding(1) ], "Identifier and literal"; + +expr_sql_is { SELECT { $_->foo => AS("foom"), 1 } } + [ "SELECT foo AS foom , ?", binding(1) ], + "AS with parens"; + +expr_sql_is { SELECT { $_->foo => AS "foom", 1 } } + [ "SELECT foo AS foom , ?", binding(1) ], + "AS without parens";