- attached many_backrefs.py
Internal SQLAlchemy extensions are multiplicated on properties in some circumstances.
Issue #1585
resolved
Under some circumstances recompiling mappers causes property.extension list to be populated with the same backref/uow extension many times in sqlalchemy.orm.strategies._register_attribute() (strategies.py, lines 41 and 47).
This causes for example adding an item to a backref property multiple times (as GenericBackrefExtension is placed many times in RelationProperty.extension).
For an attached test this can be fixed with copying provided extension list in orm.attributes.AttributeImpl constructor:
diff -ruN sqlalchemy.orig/orm/attributes.py sqlalchemy/orm/attributes.py
--- sqlalchemy.orig/orm/attributes.py 2009-10-23 16:35:40.000000000 +0200
+++ sqlalchemy/orm/attributes.py 2009-10-23 17:19:30.000000000 +0200
@@ -284,7 +284,7 @@
self.is_equal = operator.eq
else:
self.is_equal = compare_function
- self.extensions = util.to_list(extension or [ self.extensions = list(util.to_list(extension or [](])
+)))
for e in self.extensions:
if e.active_history:
active_history = True
but it still fails in our more complicated code.
Comments (3)
-
Account Deleted -
repo owner the collection is now copied before any mutations take place, c676898f67d74a99f5ada5857d390a8be937c450 52fab3ed3448205dbbc6ed8e3be0113ee78e1e0a 0.5 /0.6
-
repo owner - removed milestone
Removing milestone: 0.5.7 (automated comment)
- Log in to comment
Test file showing the problem.