invalid autoincrement setting can be reflected, causing failures
Issue #3835
resolved
from sqlalchemy import *
m = MetaData()
t = Table(
't', m,
Column(
'x', Integer, primary_key=True)
)
e = create_engine("postgresql://scott:tiger@localhost/test", echo=True)
m.drop_all(e)
m.create_all(e)
e.execute("alter table t alter column x type varchar(50)")
m2 = MetaData()
t2 = Table('t', m2, autoload_with=e)
from sqlalchemy.schema import CreateTable
print CreateTable(t2)
output:
sqlalchemy.exc.ArgumentError: Column type VARCHAR(50) on column 't.x' is not compatible with autoincrement=True
Comments (4)
-
reporter -
reporter -
reporter downstream at https://review.openstack.org/#/c/389363/
-
reporter - changed status to resolved
Don't set pg autoincrement if type affinity is not Integer
Postgresql table reflection will ensure that the :paramref:
.Column.autoincrement
flag is set to False when reflecting a primary key column that is not of an :class:.Integer
datatype, even if the default is related to an integer-generating sequence. This can happen if a column is created as SERIAL and the datatype is changed. The autoincrement flag can only be True if the datatype is of integer affinity in the 1.1 series.This bug is related to a test failure in downstream sqlalchemy_migrate.
Change-Id: I40260e47e1927a1ac940538408983c943bbdba28 Fixes:
#3835→ <<cset 232eec47d139>>
- Log in to comment
related to downstream sqlalchemy_migrate test suite, which also needs its own fix in this area.