[Dbix-class] Incorrect SQL being generated after DBIC library upgrade

Peter Rabbitson rabbit+dbic at rabbit.us
Thu Mar 19 20:35:11 GMT 2009


demerphq wrote:
> 2009/3/19 Peter Rabbitson <rabbit+dbic at rabbit.us>:
> [...]
>> Reading your example again I noticed you are actually getting what you asked for.
>> Consider (if we assume -and in a hashref is OK)
> 
> FWIW I agree with the OP.  And the docs state that -and in a hashref
> is legal as far as i recall.

I couldn't find it, we should clarify this if it is the case.

>> 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 = ?
> 
> It doesnt work like that, at least not in my experience.
> 
> The '-and => [ ... ]' is self contained, the "-and" says join together
> the next thing using "AND" (and not whatever the default join operand
> is for that type), not "join together everything following".

Precisely. You are saying -and => [ STUFF ], where:
STUFF == [ '-or', { SUBSTUFF }, SUBSTUFF2 ]

The -and [ STUFF ] asks for an unconditional AND-ing of STUFF
The -or asks for an unconditional OR-ing of the significant bits of STUFF
(SUBSTUFF and SUBSTUFF2). It is logical imo for the last request to win...

I committed a test extension[1] similar to what you wrote, except that it follows
my logic. While it is debatable which behavior is correct, it fails in either
case, either as the OP demonstrated or as currently shown in the commit.

[1] http://dev.catalyst.perl.org/svnweb/bast/revision/?rev=5775



More information about the DBIx-Class mailing list