[Dbix-class] Incorrect SQL being generated after DBIC library
upgrade
Peter Rabbitson
rabbit+dbic at rabbit.us
Thu Mar 19 18:53:20 GMT 2009
Anthony Gladdish wrote:
> Hi,
>
> Upgrading from:
>
> DBIC v0.08010
> SQL:Abstract v1.24
>
> to:
>
> DBIC v0.08012
> SQL:Abstract v1.5
>
> My ResultSet method contains following search:
>
> my $orders_current = $schema->resultset('Order')->search(
> {
> -and => [
> -or => [
> "module_access.expires" => { ">", DateTime->now() },
> "scheme_access.expires" => { ">", DateTime->now() },
> ],
> "me.person" => $self->id(),
> ],
> },
> {
> distinct => 1,
> join => ['module_access','scheme_access'],
> }
> );
>
Reading your example again I noticed you are actually getting what you asked for.
Consider (if we assume -and in a hashref is OK)
1) You say -and as in AND all the contents of the following arrayref
2) Then as first element of the array you say - OR the elements following the -or
modifier
3) The first element after OR is another arrayref - you get the
( module_access.expires > ? OR scheme_access.expires > ? ) chunk
4) Then due to the -or keyword (2) you get ... OR me.person = ?
5) Leaving the scope of the arrayref there is nothing to -and (1)
Again someone who knows SQLA internals better than me should comment, although
what 1.50 does seems very logical.
More information about the DBIx-Class
mailing list