1. Atsushi Odagiri
  2. sqlalchemy-namedfilter

Commits

Mike Bayer  committed 0d88743

dont put SERIAL on a column if it has a ForeignKey

  • Participants
  • Parent commits 244f7cf
  • Branches default

Comments (0)

Files changed (1)

File lib/sqlalchemy/databases/postgres.py

View file
         
     def get_column_specification(self, column, override_pk=False, **kwargs):
         colspec = column.name
-        if column.primary_key and isinstance(column.type, sqltypes.Integer) and (column.default is None or (isinstance(column.default, schema.Sequence) and column.default.optional)):
+        if column.primary_key and not column.foreign_key and isinstance(column.type, sqltypes.Integer) and (column.default is None or (isinstance(column.default, schema.Sequence) and column.default.optional)):
             colspec += " SERIAL"
         else:
             colspec += " " + column.type.engine_impl(self.engine).get_col_spec()