From: Mike Bayer Date: Mon, 26 Jun 2006 20:01:56 +0000 (+0000) Subject: dont put SERIAL on a column if it has a ForeignKey X-Git-Tag: rel_0_2_4~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8438ad748253e737bdf839bb5cebd58cdf941025;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git dont put SERIAL on a column if it has a ForeignKey --- diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 50d67ad561..de21bd570d 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -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()