1. Daniel Miller
  2. sqlalchemy

Commits

rtl  committed 59f5bfb

Modified mysql to not add AUTOINCREMENT to the first integer primary key if it is also a foreign key.

  • Participants
  • Parent commits b744592
  • Branches default

Comments (0)

Files changed (1)

File lib/sqlalchemy/databases/mysql.py

View file
         if column.primary_key:
             if not override_pk:
                 colspec += " PRIMARY KEY"
-            if first_pk and isinstance(column.type, types.Integer):
+            if not column.foreign_key and first_pk and isinstance(column.type, types.Integer):
                 colspec += " AUTO_INCREMENT"
         if column.foreign_key:
             colspec += ", FOREIGN KEY (%s) REFERENCES %s(%s)" % (column.name, column.foreign_key.column.table.name, column.foreign_key.column.name)