[Dbix-class] Chaining search, +select and SQL as
Ryan Tate
ryantate at ryantate.com
Sat Nov 27 22:07:26 GMT 2010
Lord knows it could be another of my mistakes, but there seems to be
an issue chaining +selects when either or both +selects contains an
"-as" clause (the SQL aliasing, not the DBIx::Class aliasing). For
example, this:
my $artist = $schema->resultset('Artist')->search(
{},
{
'+select' => [ {max => 'me.artistid', -as=>'idmax'} ],
}
)->search(
{},
{
'+select' => [ {sum => 'me.artistid', -as=> 'idsum' } ],
}
)->first;
...produces "DBIx::Class::ResultSet::first(): DBI Exception:
DBD::SQLite::db prepare_cached failed: near ")": syntax error [for
Statement "SELECT me.artistid, me.name, ( ) AS ARRAY(0x8c77c68), MAX(
me.artistid ), SUM( me.artistid ) FROM artist me"] at
/home/ryantate/tmp/dbix_chainedselect.t line 68" and I see similar
under MySQL.
The problem only happens when you have that "-as" clause in either of
the search +selects; remove both and this runs fine. (Of course adding
+as clauses to the searches does not help which makes sense as those
are just for DBIx::Class aliasing.)
There was a different/similar bug a couple of years ago
http://lists.scsys.co.uk/pipermail/dbix-class/2008-October/006915.html
that resulted in a patch
http://lists.scsys.co.uk/pipermail/dbix-class/2008-October/006941.html.
That old problem is fixed but this twist remains, perhaps....
....or maybe I'm overlooking something
More information about the DBIx-Class
mailing list