diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-06-20 11:39:01 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-06-20 12:52:31 -0400 |
commit | bf03d4332ae35e2087b175f8a2e0291d2f4c9aa0 (patch) | |
tree | 8eadf8feeab0e2a677a8385125251b17bf715b1c /test/sql/test_compiler.py | |
parent | 91a1022227499c8efce038c4a0a9bdcdb14a69d0 (diff) | |
download | sqlalchemy-bf03d4332ae35e2087b175f8a2e0291d2f4c9aa0.tar.gz |
Don't reorder PrimaryKeyConstraint columns if explicit
Dialed back the "order the primary key columns per auto-increment"
described in :ref:`change_mysql_3216` a bit, so that if the
:class:`.PrimaryKeyConstraint` is explicitly defined, the order
of columns is maintained exactly, allowing control of this behavior
when necessary.
Change-Id: I9e7902c57a96c15968a6abf53e319acf15680da0
Fixes: #3726
Diffstat (limited to 'test/sql/test_compiler.py')
-rw-r--r-- | test/sql/test_compiler.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index 8b4e5053b..27cab65ac 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -3066,7 +3066,7 @@ class DDLTest(fixtures.TestBase, AssertsCompiledSQL): "CREATE TABLE t (x INTEGER, z INTEGER)" ) - def test_composite_pk_constraint_autoinc_first(self): + def test_composite_pk_constraint_autoinc_first_implicit(self): m = MetaData() t = Table( 't', m, @@ -3081,6 +3081,22 @@ class DDLTest(fixtures.TestBase, AssertsCompiledSQL): "PRIMARY KEY (b, a))" ) + def test_composite_pk_constraint_maintains_order_explicit(self): + m = MetaData() + t = Table( + 't', m, + Column('a', Integer), + Column('b', Integer, autoincrement=True), + schema.PrimaryKeyConstraint('a', 'b') + ) + self.assert_compile( + schema.CreateTable(t), + "CREATE TABLE t (" + "a INTEGER NOT NULL, " + "b INTEGER NOT NULL, " + "PRIMARY KEY (a, b))" + ) + def test_create_table_suffix(self): class MyDialect(default.DefaultDialect): class MyCompiler(compiler.DDLCompiler): |