diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-04-01 13:37:35 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-04-01 13:37:35 -0400 |
commit | 82b6e074920cb972a569db4d2d395c8949868a31 (patch) | |
tree | d18df886d56a5c9873011bd3b4c84f057ee6bf8a /test/orm/inheritance/test_basic.py | |
parent | 7dff6f6d490528f5e88493cdf4b14d3136b40d3c (diff) | |
download | sqlalchemy-82b6e074920cb972a569db4d2d395c8949868a31.tar.gz |
- Fixed bug in unit of work whereby a joined-inheritance
subclass could insert the row for the "sub" table
before the parent table, if the two tables had no
ForeignKey constraints set up between them.
Also in 0.7.11. [ticket:2689]
- fix a glitch in the assertsql.CompiledSQL fixture regarding
when a multiparam compiledSQL is used within an AllOf
- add a new utility function randomize_unitofwork() which
does the function of --reversetop
Diffstat (limited to 'test/orm/inheritance/test_basic.py')
-rw-r--r-- | test/orm/inheritance/test_basic.py | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/test/orm/inheritance/test_basic.py b/test/orm/inheritance/test_basic.py index 66991e922..3cd3db928 100644 --- a/test/orm/inheritance/test_basic.py +++ b/test/orm/inheritance/test_basic.py @@ -1055,6 +1055,73 @@ class FlushTest(fixtures.MappedTest): sess.flush() assert user_roles.count().scalar() == 1 +class JoinedNoFKSortingTest(fixtures.MappedTest): + @classmethod + def define_tables(cls, metadata): + Table("a", metadata, + Column('id', Integer, primary_key=True, + test_needs_autoincrement=True) + ) + Table("b", metadata, + Column('id', Integer, primary_key=True) + ) + Table("c", metadata, + Column('id', Integer, primary_key=True) + ) + + @classmethod + def setup_classes(cls): + class A(cls.Basic): + pass + class B(A): + pass + class C(A): + pass + + @classmethod + def setup_mappers(cls): + A, B, C = cls.classes.A, cls.classes.B, cls.classes.C + mapper(A, cls.tables.a) + mapper(B, cls.tables.b, inherits=A, + inherit_condition=cls.tables.a.c.id == cls.tables.b.c.id) + mapper(C, cls.tables.c, inherits=A, + inherit_condition=cls.tables.a.c.id == cls.tables.c.c.id) + + def test_ordering(self): + B, C = self.classes.B, self.classes.C + sess = Session() + sess.add_all([B(), C(), B(), C()]) + self.assert_sql_execution( + testing.db, + sess.flush, + CompiledSQL( + "INSERT INTO a () VALUES ()", + {} + ), + CompiledSQL( + "INSERT INTO a () VALUES ()", + {} + ), + CompiledSQL( + "INSERT INTO a () VALUES ()", + {} + ), + CompiledSQL( + "INSERT INTO a () VALUES ()", + {} + ), + AllOf( + CompiledSQL( + "INSERT INTO b (id) VALUES (:id)", + [{"id": 1}, {"id": 3}] + ), + CompiledSQL( + "INSERT INTO c (id) VALUES (:id)", + [{"id": 2}, {"id": 4}] + ) + ) + ) + class VersioningTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): |