- changed status to resolved
cant set association proxy collection to None
Issue #597
resolved
Starting with r2598, I'm seeing some failures with how I'm using the association proxy. I've modified the examples/association/proxied_association.py file which duplicates the problem.
It is possible that I'm not suppose to remove associations like I am. But it did work before (in 0.3.7 and 0.3.6).
It looks like if I read in part of the association into the current session and then delete it, things don't go so well.
Index: examples/association/proxied_association.py
===================================================================
--- examples/association/proxied_association.py (revision 2723)
+++ examples/association/proxied_association.py (working copy)
@@ -106,8 +106,18 @@
+# new additions to proxied_association.py
+#engine.echo = True
+new_item = Item('new item', 100)
+session.clear()
+order = session.query(Order).get_by(customer_name='john smith')
+bogus = order.items[0](0).item_id # comment out and it works on 0.3.8
+order.itemassociations = None
+session.flush()
+order.items.append(new_item)
+session.flush()
It fails with:
sqlalchemy.exceptions.SQLError: (IntegrityError) orderitems.order_id
may not be NULL u'INSERT INTO orderitems (item_id, price) VALUES (?,
?)' [100](5,)
Comments (1)
-
- Log in to comment
Fixed in changeset:2730.
Also, a heads up that assigning None to a collection attribute will raise an exception in 0.4.