summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-01-19 13:34:42 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2016-01-19 13:34:42 -0500
commitb7bc704f3d05bed8d0771cbff65adcdb7b49f796 (patch)
tree9e4cc6cd321fb38c64a65be653e9ce8220836e64 /test
parent2a7f37b7b01930fb4e9227e5cab03ea26e0a4b55 (diff)
downloadsqlalchemy-b7bc704f3d05bed8d0771cbff65adcdb7b49f796.tar.gz
- Fixed issue where two same-named relationships that refer to
a base class and a concrete-inherited subclass would raise an error if those relationships were set up using "backref", while setting up the identical configuration using relationship() instead with the conflicting names would succeed, as is allowed in the case of a concrete mapping. fixes #3630
Diffstat (limited to 'test')
-rw-r--r--test/orm/inheritance/test_concrete.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/orm/inheritance/test_concrete.py b/test/orm/inheritance/test_concrete.py
index 573913f74..2539d4737 100644
--- a/test/orm/inheritance/test_concrete.py
+++ b/test/orm/inheritance/test_concrete.py
@@ -486,6 +486,45 @@ class PropertyInheritanceTest(fixtures.MappedTest):
assert dest1.many_b == [b1, b2]
assert sess.query(B).filter(B.bname == 'b1').one() is b1
+ def test_overlapping_backref_relationship(self):
+ A, B, b_table, a_table, Dest, dest_table = (
+ self.classes.A,
+ self.classes.B,
+ self.tables.b_table,
+ self.tables.a_table,
+ self.classes.Dest,
+ self.tables.dest_table)
+
+ # test issue #3630, no error or warning is generated
+ mapper(A, a_table)
+ mapper(B, b_table, inherits=A, concrete=True)
+ mapper(Dest, dest_table, properties={
+ 'a': relationship(A, backref='dest'),
+ 'a1': relationship(B, backref='dest')
+ })
+ configure_mappers()
+
+ def test_overlapping_forwards_relationship(self):
+ A, B, b_table, a_table, Dest, dest_table = (
+ self.classes.A,
+ self.classes.B,
+ self.tables.b_table,
+ self.tables.a_table,
+ self.classes.Dest,
+ self.tables.dest_table)
+
+ # this is the opposite mapping as that of #3630, never generated
+ # an error / warning
+ mapper(A, a_table, properties={
+ 'dest': relationship(Dest, backref='a')
+ })
+ mapper(B, b_table, inherits=A, concrete=True, properties={
+ 'dest': relationship(Dest, backref='a1')
+ })
+ mapper(Dest, dest_table)
+ configure_mappers()
+
+
def test_polymorphic_backref(self):
"""test multiple backrefs to the same polymorphically-loading
attribute."""