summaryrefslogtreecommitdiff
path: root/alembic/autogenerate
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-11-02 12:35:47 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2014-11-02 12:35:47 -0500
commit92184a55cac2c0fa04396df4b2d4d9694e97f43f (patch)
treefa0f5a7404baa447236b6c74e98272b9bfc861c2 /alembic/autogenerate
parentb16bdf8789cc3f16fd6a5a94288ba204646bbc23 (diff)
downloadalembic-92184a55cac2c0fa04396df4b2d4d9694e97f43f.tar.gz
- Added a workaround for SQLAlchemy issue #3023 (fixed in 0.9.5) where
a column that's part of an explicit PrimaryKeyConstraint would not have its "nullable" flag set to False, thus producing a false autogenerate. Also added a related correction to MySQL which will correct for MySQL's implicit server default of '0' when a NULL integer column is turned into a primary key column. fixes #199
Diffstat (limited to 'alembic/autogenerate')
-rw-r--r--alembic/autogenerate/compare.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/alembic/autogenerate/compare.py b/alembic/autogenerate/compare.py
index dbc7b9f..1a87d66 100644
--- a/alembic/autogenerate/compare.py
+++ b/alembic/autogenerate/compare.py
@@ -167,11 +167,13 @@ def _compare_columns(schema, tname, object_filters, conn_table, metadata_table,
metadata_col,
col_diff, autogen_context
)
- _compare_nullable(schema, tname, colname,
- conn_col,
- metadata_col.nullable,
- col_diff, autogen_context
- )
+ # work around SQLAlchemy issue #3023
+ if not metadata_col.primary_key:
+ _compare_nullable(schema, tname, colname,
+ conn_col,
+ metadata_col.nullable,
+ col_diff, autogen_context
+ )
_compare_server_default(schema, tname, colname,
conn_col,
metadata_col,