]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed regression from 0.9.10 prior to release due to :ticket:`3349`
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 1 May 2015 01:26:48 +0000 (21:26 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 1 May 2015 01:30:57 +0000 (21:30 -0400)
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)

doc/build/changelog/changelog_09.rst
lib/sqlalchemy/orm/persistence.py

index 778881b909bba789a8709cf5a084e9b335d655a4..f23acbb6f7226d0c0b66044dc7a2ce52f443dd59 100644 (file)
@@ -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
index 6f2c278948d7759f6062d3a2759d940b6b508924..6803693e56f58543fa93bcd8001908caaffc40ac 100644 (file)
@@ -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() "