Subject: | GenericSubQ doesn't handle empty 'where' clause |
The sql generated when there is no 'where' value is incorrect.
This code:
@order = ();
@fields = ('artistid, name');
%where = ();
$stmt = $sql->select('artist', \@fields, \%where, \@order, 3, 2 );
print $stmt . "\n";
Produces:
SELECT artistid, name FROM artist AND
(
SELECT COUNT(*) FROM artist WHERE artistid > X.artistid
)
BETWEEN 2 AND 5
ORDER BY artistid DESC
And this code:
$stmt = $sql->select('artist', \@fields, '', \@order, 3, 2 );
print $stmt . "\n";
Produces:
SELECT artistid, name FROM artist X WHERE ( ) AND
(
SELECT COUNT(*) FROM artist WHERE artistid > X.artistid
)
BETWEEN 2 AND 5
ORDER BY artistid DESC