Commits

Mike Bayer committed f2cf620

- Fixed bug involving dynamic attributes, that was again a regression
of ticket`3060` from verision 0.9.5. A self-referential relationship
with lazy='dynamic' would raise a TypeError within a flush operation.
fixes #3099

Comments (0)

Files changed (3)

doc/build/changelog/changelog_09.rst

     :released:
 
     .. change::
+        :tags: bug, orm
+        :tickets: 3099
+
+        Fixed bug involving dynamic attributes, that was again a regression
+        of :ticket:`3060` from verision 0.9.5.  A self-referential relationship
+        with lazy='dynamic' would raise a TypeError within a flush operation.
+
+    .. change::
         :tags: bug, declarative
         :tickets: 3097
         :versions: 1.0.0

lib/sqlalchemy/orm/dynamic.py

         c = self._get_collection_history(state, passive)
         return c.as_history()
 
-    def get_all_pending(self, state, dict_):
+    def get_all_pending(self, state, dict_,
+                                passive=attributes.PASSIVE_NO_INITIALIZE):
         c = self._get_collection_history(
-            state, attributes.PASSIVE_NO_INITIALIZE)
+            state, passive)
         return [
                 (attributes.instance_state(x), x)
                 for x in

test/orm/test_dynamic.py

     def test_delete_cascade(self):
         self._test_delete_cascade(False)
 
+    def test_self_referential(self):
+        Node, nodes = self.classes.Node, self.tables.nodes
+
+
+        mapper(Node, nodes, properties={
+            'children': relationship(Node, lazy="dynamic", order_by=nodes.c.id)
+        })
+
+        sess = Session()
+        n2, n3 = Node(), Node()
+        n1 = Node(children=[n2, n3])
+        sess.add(n1)
+        sess.commit()
+
+        eq_(n1.children.all(), [n2, n3])
+
+
     def test_remove_orphans(self):
         addresses = self.tables.addresses
         User, Address = self._user_address_fixture(addresses_args={