diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-09-04 17:44:48 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-09-04 17:44:48 +0000 |
commit | 94c32b19a08182aa5403a893ffd037994199ca44 (patch) | |
tree | 15e08f101e7292cbf4a636bccbeea97f28f74bcd /test/ext/declarative.py | |
parent | cd8a3390e6992a1a969af47ee6268456d7890aa8 (diff) | |
download | sqlalchemy-94c32b19a08182aa5403a893ffd037994199ca44.tar.gz |
- Fixed bug whereby mapper couldn't initialize if a composite
primary key referenced another table that was not defined
yet [ticket:1161]
Diffstat (limited to 'test/ext/declarative.py')
-rw-r--r-- | test/ext/declarative.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ext/declarative.py b/test/ext/declarative.py index 6b226cc9f..3121f959f 100644 --- a/test/ext/declarative.py +++ b/test/ext/declarative.py @@ -679,6 +679,22 @@ class DeclarativeTest(testing.TestBase, testing.AssertsExecutionResults): Address(email='one'), Address(email='two')])]) + def test_pk_with_fk_init(self): + class Bar(Base): + __tablename__ = 'bar' + + id = sa.Column(sa.Integer, sa.ForeignKey("foo.id"), primary_key=True) + ex = sa.Column(sa.Integer, primary_key=True) + + class Foo(Base): + __tablename__ = 'foo' + + id = sa.Column(sa.Integer, primary_key=True) + bars = sa.orm.relation(Bar) + + assert Bar.__mapper__.primary_key[0] is Bar.__table__.c.id + assert Bar.__mapper__.primary_key[1] is Bar.__table__.c.ex + def test_single_inheritance(self): class Company(Base, ComparableEntity): __tablename__ = 'companies' |