summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-06-20 11:39:01 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2016-06-20 12:52:31 -0400
commitbf03d4332ae35e2087b175f8a2e0291d2f4c9aa0 (patch)
tree8eadf8feeab0e2a677a8385125251b17bf715b1c /lib/sqlalchemy/sql/compiler.py
parent91a1022227499c8efce038c4a0a9bdcdb14a69d0 (diff)
downloadsqlalchemy-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 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r--lib/sqlalchemy/sql/compiler.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index fc5073596..16ca7f959 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -2519,7 +2519,9 @@ class DDLCompiler(Compiled):
text += "CONSTRAINT %s " % formatted_name
text += "PRIMARY KEY "
text += "(%s)" % ', '.join(self.preparer.quote(c.name)
- for c in constraint.columns_autoinc_first)
+ for c in (constraint.columns_autoinc_first
+ if constraint._implicit_generated
+ else constraint.columns))
text += self.define_constraint_deferrability(constraint)
return text