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_0_9_10~35 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7f658511954d8b1fda7fddf5c8b74f6274beed9a;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 (cherry picked from commit 681276b5b4ae48924c85a1c26af3f9bde3d77b5f) --- diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst index 778881b909..f23acbb6f7 100644 --- a/doc/build/changelog/changelog_09.rst +++ b/doc/build/changelog/changelog_09.rst @@ -57,6 +57,8 @@ fields if methods like :meth:`.Query.join` or :meth:`.Query.select_from` has been called, a warning is emitted. As of 1.0.0b5 this will raise an error. + See also :ticket:`3405` which repaired a regression in this feature + which was unreleased in 0.9.10 but was released in the 1.0 version. .. change:: :tags: bug, orm diff --git a/lib/sqlalchemy/orm/persistence.py b/lib/sqlalchemy/orm/persistence.py index 6f2c278948..6803693e56 100644 --- a/lib/sqlalchemy/orm/persistence.py +++ b/lib/sqlalchemy/orm/persistence.py @@ -878,18 +878,18 @@ class BulkUD(object): self._validate_query_state() def _validate_query_state(self): - for attr, methname, notset, err in ( - ('_limit', 'limit()', None, True), - ('_offset', 'offset()', None, True), - ('_order_by', 'order_by()', False, True), - ('_group_by', 'group_by()', False, True), - ('_distinct', 'distinct()', False, True), + for attr, methname, notset, op, err in ( + ('_limit', 'limit()', None, operator.is_, True), + ('_offset', 'offset()', None, operator.is_, True), + ('_order_by', 'order_by()', False, operator.is_, True), + ('_group_by', 'group_by()', False, operator.is_, True), + ('_distinct', 'distinct()', False, operator.is_, True), ( '_from_obj', 'join(), outerjoin(), select_from(), or from_self()', - (), False) + (), operator.eq, False) ): - if getattr(self.query, attr) is not notset: + if not op(getattr(self.query, attr), notset): if err: raise sa_exc.InvalidRequestError( "Can't call Query.update() or Query.delete() "