Subject: | GenericSubQ doesn't handle table alias |
If you have a table name using an alias the generated SQL is bad.
Code:
my @fields = ('me.artistid, me.name');
my %where = ( 'me.artistid' => { '>' => 0} );
my @order = ('me.artistid');
my $sql = SQL::Abstract::Limit->new( limit_dialect => "GenericSubQ");
my $stmt = $sql->select('artist me', \@fields, \%where, \@order, 3, 2 );
print $stmt . "\n";
Produces:
SELECT me.artistid, me.name FROM artist X me WHERE ( me.artistid > ? ) AND
(
SELECT COUNT(*) FROM artist WHERE me > X.me
)
BETWEEN 2 AND 5
ORDER BY me DESC
Note the problematic SQL following the first FROM and the second WHERE.