.. changelog::
:version: 0.9.9
+ .. change::
+ :tags: bug, orm
+ :versions: 1.0.0
+ :tickets: 3251
+
+ Fixed a leak which would occur in the unsupported and highly
+ non-recommended use case of replacing a relationship on a fixed
+ mapped class many times, referring to an arbitrarily growing number of
+ target mappers. A warning is emitted when the old relationship is
+ replaced, however if the mapping were already used for querying, the
+ old relationship would still be referenced within some registries.
+
.. change::
:tags: bug, sql
:versions: 1.0.0
row[t.c.x]
go()
+ def test_many_discarded_relationships(self):
+ """a use case that really isn't supported, nonetheless we can
+ guard against memleaks here so why not"""
+
+ m1 = MetaData()
+ t1 = Table('t1', m1, Column('id', Integer, primary_key=True))
+ t2 = Table(
+ 't2', m1, Column('id', Integer, primary_key=True),
+ Column('t1id', ForeignKey('t1.id')))
+
+ class T1(object):
+ pass
+ t1_mapper = mapper(T1, t1)
+
+ @testing.emits_warning()
+ @profile_memory()
+ def go():
+ class T2(object):
+ pass
+ t2_mapper = mapper(T2, t2)
+ t1_mapper.add_property("bar", relationship(t2_mapper))
+ s1 = Session()
+ # this causes the path_registry to be invoked
+ s1.query(t1_mapper)._compile_context()
+ go()
+
# fails on newer versions of pysqlite due to unusual memory behvior
# in pysqlite itself. background at:
# http://thread.gmane.org/gmane.comp.python.db.pysqlite.user/2290