]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Reverted the change for :ticket:`3060` - this is a unit of work
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 23 Jun 2014 22:38:23 +0000 (18:38 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 23 Jun 2014 22:38:23 +0000 (18:38 -0400)
fix that is updated more comprehensively in 1.0 via :ticket:`3061`.
The fix in :ticket:`3060` unfortunately produces a new issue whereby
an eager load of a many-to-one attribute can produce an event
that is interpreted into an attribute change.

doc/build/changelog/changelog_09.rst
lib/sqlalchemy/orm/dependency.py
lib/sqlalchemy/testing/__init__.py
test/orm/test_unitofworkv2.py

index f3c55a2053af45988e2192498469e50e09dbc991..77fc58148f7b73d0cdba1e6b805abd63c8f67866 100644 (file)
     .. include:: changelog_07.rst
         :start-line: 5
 
+.. changelog::
+    :version: 0.9.6
+    :released:
+
+    .. change::
+        :tags: bug, orm
+        :tickets: 3060
+
+        Reverted the change for :ticket:`3060` - this is a unit of work
+        fix that is updated more comprehensively in 1.0 via :ticket:`3061`.
+        The fix in :ticket:`3060` unfortunately produces a new issue whereby
+        an eager load of a many-to-one attribute can produce an event
+        that is interpreted into an attribute change.
+
 .. changelog::
     :version: 0.9.5
     :released: June 23, 2014
         of implicitly assuming None isn't really a "change" for a previously
         un-set attribute.  See also :ticket:`3061`.
 
+        .. note::
+
+            This change has been **REVERTED** in 0.9.6.   The full fix
+            will be in version 1.0 of SQLAlchemy.
+
+
     .. change::
         :tags: bug, orm
         :versions: 1.0.0
index bfe7aa0d253bca2d0e339ee04ada019faa525b71..40d6bd77627db2029263086675d2727073e0c71b 100644 (file)
@@ -749,11 +749,6 @@ class ManyToOneDP(DependencyProcessor):
                     for child in history.added:
                         self._synchronize(state, child, None, False,
                                                 uowcommit, "add")
-                elif history.unchanged == [None]:
-                    # this is to appease the case where our row
-                    # here is in fact going to be a so-called "row switch",
-                    # where an INSERT becomes an UPDATE.  See #3060.
-                    self._synchronize(state, None, None, True, uowcommit)
                 if self.post_update:
                     self._post_update(state, uowcommit, history.sum())
 
index 95490643220d9f383e2de189766721adcf488c08..c03c6f349f09533dd445dcb5a43f49126980dd11 100644 (file)
@@ -11,7 +11,7 @@ from . import config
 
 from .exclusions import db_spec, _is_excluded, fails_if, skip_if, future,\
     fails_on, fails_on_everything_except, skip, only_on, exclude, \
-    against as _against, _server_version, only_if
+    against as _against, _server_version, only_if, fails
 
 
 def against(*queries):
index 00cc044bfa37f1c4ce9f2d2d3680952d6f43b4c7..787c104e7e537f6ab87d690d2c7cce9b8b28d358 100644 (file)
@@ -1314,6 +1314,7 @@ class RowswitchM2OTest(fixtures.MappedTest):
         mapper(C, c)
         return A, B, C
 
+    @testing.fails()
     def test_set_none_replaces_m2o(self):
         # we have to deal here with the fact that a
         # get of an unset attribute implicitly sets it to None
@@ -1337,6 +1338,7 @@ class RowswitchM2OTest(fixtures.MappedTest):
         sess.commit()
         assert a1.bs[0].c is None
 
+    @testing.fails()
     def test_set_none_w_get_replaces_m2o(self):
         A, B, C = self._fixture()
         sess = Session()
@@ -1389,6 +1391,25 @@ class RowswitchM2OTest(fixtures.MappedTest):
         sess.commit()
         assert a1.bs[0].data is None
 
+    def test_joinedload_doesnt_produce_bogus_event(self):
+        A, B, C = self._fixture()
+        sess = Session()
+
+        c1 = C()
+        sess.add(c1)
+        sess.flush()
+
+        b1 = B()
+        sess.add(b1)
+        sess.commit()
+
+        # test that was broken by #3060
+        from sqlalchemy.orm import joinedload
+        b1 = sess.query(B).options(joinedload("c")).first()
+        b1.cid = c1.id
+        sess.flush()
+
+        assert b1.cid == c1.id
 
 
 class BasicStaleChecksTest(fixtures.MappedTest):