geez..its 10 degrees here, sorry, just scratch that first case, it has to be like this to be fully compatible both ways:
def my_select(conditions):
stmt = select([column('x')])
if conditions:
stmt = stmt.where(and_(*conditions))
return stmt
“cond & None” was never any kind of publicly documented behavior and it was
inconsistent, sorry.
On Jan 8, 2014, at 11:22 AM, Michael Bayer <[email protected]> wrote:
> sorry, this should read:
>
> "Therefore, your script cannot work in either 0.8 or 0.9, unless you fix it
> as follows, in which case it works the same in both versions:"
>
> def my_select(conditions):
> cond = None
> for c in conditions:
> cond = c & cond
> stmt = select([column(‘x’)])
> if cond is not None:
> stmt = stmt.where(cond)
> return stmt
>
>
>
> On Jan 8, 2014, at 11:20 AM, Michael Bayer <[email protected]> wrote:
>
>> Therefore, your script cannot work in either 0.8 or 0.9, unless you fix it
>> as follows, in which case it works the same in both versions:
>>
>> def my_select(conditions):
>> cond = conditions[0]
>> for c in conditions[1:]:
>> cond = c & cond
>> stmt = select([column(‘x’)])
>> if cond is not None:
>> stmt = stmt.where(cond)
>> return stmt
>>
>> or you assume that “conditions” is non-empty, in which case, as I mentioned
>> earlier, do this:
>>
>> def my_select(conditions):
>> cond = conditions[0]
>> for c in conditions[1:]:
>> cond = c & cond
>>
>> return select([column('x')]).where(cond)
>
signature.asc
Description: Message signed with OpenPGP using GPGMail
