a new section has been added as the first “Core Behavioral Change”: http://sqlalchemy.readthedocs.org/en/rel_0_9/changelog/migration_09.html#none-can-no-longer-be-used-as-a-partial-and-constructor
On Jan 8, 2014, at 11:27 AM, Michael Bayer <mike...@zzzcomputing.com> wrote: > > 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 <mike...@zzzcomputing.com> 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 <mike...@zzzcomputing.com> 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