Internal SQLAlchemy extensions are multiplicated on properties in some circumstances.

Issue #1585 resolved
Former user created an issue

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)

  1. Log in to comment