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

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to