From: Mike Bayer Date: Fri, 1 May 2015 01:26:48 +0000 (-0400) Subject: - Fixed regression from 0.9.10 prior to release due to :ticket:`3349` X-Git-Tag: rel_1_0_3~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=681276b5b4ae48924c85a1c26af3f9bde3d77b5f;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Fixed regression from 0.9.10 prior to release due to :ticket:`3349` where the check for query state on :meth:`.Query.update` or :meth:`.Query.delete` compared the empty tuple to itself using ``is``, which fails on Pypy to produce ``True`` in this case; this would erronously emit a warning in 0.9 and raise an exception in 1.0. fixes #3405 --- diff --git a/doc/build/changelog/changelog_10.rst b/doc/build/changelog/changelog_10.rst index fe5c7a7447..09ffcddc9d 100644 --- a/doc/build/changelog/changelog_10.rst +++ b/doc/build/changelog/changelog_10.rst @@ -18,6 +18,16 @@ .. changelog:: :version: 1.0.3 + .. change:: + :tags: bug, orm, pypy + :tickets: 3405 + + Fixed regression from 0.9.10 prior to release due to :ticket:`3349` + where the check for query state on :meth:`.Query.update` or + :meth:`.Query.delete` compared the empty tuple to itself using ``is``, + which fails on Pypy to produce ``True`` in this case; this would + erronously emit a warning in 0.9 and raise an exception in 1.0. + .. change:: :tags: feature, engine :tickets: 3379 @@ -52,7 +62,7 @@ :tags: bug, orm :tickets: 3403, 3320 - Fixed regression from as yet unreleased 0.9.10 where the new addition + Fixed regression from 0.9.10 prior to release where the new addition of ``entity`` to the :attr:`.Query.column_descriptions` accessor would fail if the target entity was produced from a core selectable such as a :class:`.Table` or :class:`.CTE` object. diff --git a/lib/sqlalchemy/orm/persistence.py b/lib/sqlalchemy/orm/persistence.py index c3974ed6d0..ab2d54d901 100644 --- a/lib/sqlalchemy/orm/persistence.py +++ b/lib/sqlalchemy/orm/persistence.py @@ -1034,18 +1034,18 @@ class BulkUD(object): self._validate_query_state() def _validate_query_state(self): - for attr, methname, notset in ( - ('_limit', 'limit()', None), - ('_offset', 'offset()', None), - ('_order_by', 'order_by()', False), - ('_group_by', 'group_by()', False), - ('_distinct', 'distinct()', False), + for attr, methname, notset, op in ( + ('_limit', 'limit()', None, operator.is_), + ('_offset', 'offset()', None, operator.is_), + ('_order_by', 'order_by()', False, operator.is_), + ('_group_by', 'group_by()', False, operator.is_), + ('_distinct', 'distinct()', False, operator.is_), ( '_from_obj', 'join(), outerjoin(), select_from(), or from_self()', - ()) + (), operator.eq) ): - if getattr(self.query, attr) is not notset: + if not op(getattr(self.query, attr), notset): raise sa_exc.InvalidRequestError( "Can't call Query.update() or Query.delete() " "when %s has been called" %