>
>
> “WHERE NULL” is not valid, that’s true; hence neither is
> select.where(None) anymore, which is what would happen above if
> “conditions” were empty (and if conditions is guaranteed not empty, you
> could say “cond = conditions[0]; for c in conditions[1:]:…” )
>
> The change includes that it’s safe to use “true()” explicitly and it will
> be folded in (i.e. not rendered) when used with “AND”.   Some people were
> doing the above pattern that way anyway, now that way works on all backends.
>
> in any case it’s better to use and_():
>
> cond = and_(*conditions)
>
> it’s less code and way fewer method calls internally. Also when you have
> “cond = c & cond”, you end up with a structure like "a & (b & (c & (d &
> e)))” which eventually will cause a recursion overflow when parsed, if
> there’s too many conditions.
>
>
>
>
I think there are two things here:

1. Should None be converted to NULL when deal with "condition & None" or
"and_(condition, None)"
2. How to combine multiple condition into one condition with and_

And I think the second question should be resolved by application itself,
we just need to obey some good guide, that's ok.

But for the first question, the old style I think None's behavior just like
true(), but in 0.9.x, is not. So this makes the uncompatible process. Here
is a test for 0.9.1:

>>> print and_('id=3', None)
id=3 AND NULL
>>> print and_('id=3', '')
id=3
>>> print and_('id=3', true())
id=3

So empty string is the same as true(), and why empty string can be treated
as true() but None is treated as NULL? Commonly, python will treat None,
empty string are false boolean value, but here sqlalchemy does do like
that obviousely.

-- 
I like python!
UliPad <<The Python Editor>>: http://code.google.com/p/ulipad/
UliWeb <<simple web framework>>: https://github.com/limodou/uliweb
My Blog: http://my.oschina.net/limodou

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to