[Dbix-class] Incorrect SQL being generated after DBIC library
upgrade
Peter Rabbitson
rabbit+dbic at rabbit.us
Thu Mar 19 18:27:37 GMT 2009
Anthony Gladdish wrote:
> Hi,
>
> Upgrading from:
>
> DBIC v0.08010
> SQL:Abstract v1.24
>
> to:
>
> DBIC v0.08012
> SQL:Abstract v1.5
08010 and 08012 are identical (it was a maintenance release, no functional changes at all)
> 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'],
> }
> );
>
This looks like improper syntax to me. The -[and|or|nest] modifiers are
explicitly said to work in an arrayref only, yet you plug -and into a
hashref. The proper way to express what you want is (I think):
->search(
[
-and => [
[
"module_access.expires" => { ">", DateTime->now() },
"scheme_access.expires" => { ">", DateTime->now() },
],
"me.person" => $self->id(),
],
],
...
>From the DBIC 0.08012 cookbook "Complex WHERE clauses" documentation, it looks like my original search() should work?!
Indeed the book refers to modifiers within a hashref. Someone care to comment?
More information about the DBIx-Class
mailing list