]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
dont put SERIAL on a column if it has a ForeignKey
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 26 Jun 2006 20:01:56 +0000 (20:01 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 26 Jun 2006 20:01:56 +0000 (20:01 +0000)
lib/sqlalchemy/databases/postgres.py

index 50d67ad5617fcf5f584bbf1e56aa2498865b4cb8..de21bd570dd6cb6a6d4b3caa33699d38db81a57a 100644 (file)
@@ -331,7 +331,7 @@ class PGSchemaGenerator(ansisql.ANSISchemaGenerator):
         
     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()