summaryrefslogtreecommitdiff
path: root/test/aaa_profiling
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-11-13 13:17:38 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2014-11-13 13:17:38 -0500
commit026449c15ff35a9b89c2ca591d3e3cc791857272 (patch)
treec7534832b2f40abec2a4b40a9009920cfe71bd87 /test/aaa_profiling
parent64e53f26a538e4965fcab76b1a457f15a43a0d0c (diff)
downloadsqlalchemy-026449c15ff35a9b89c2ca591d3e3cc791857272.tar.gz
- 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. fixes #3251
Diffstat (limited to 'test/aaa_profiling')
-rw-r--r--test/aaa_profiling/test_memusage.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/aaa_profiling/test_memusage.py b/test/aaa_profiling/test_memusage.py
index f4bce6b01..63883daac 100644
--- a/test/aaa_profiling/test_memusage.py
+++ b/test/aaa_profiling/test_memusage.py
@@ -658,6 +658,32 @@ class MemUsageTest(EnsureZeroed):
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