Skip to content

invalid autoincrement setting can be reflected, causing failures #3835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sqlalchemy-bot opened this issue Oct 20, 2016 · 5 comments
Closed
Labels
bug Something isn't working schema things related to the DDL related objects like Table, Column, CreateIndex, etc.
Milestone

Comments

@sqlalchemy-bot
Copy link
Collaborator

Migrated issue, originally created by Michael Bayer (@zzzeek)

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
@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

related to downstream sqlalchemy_migrate test suite, which also needs its own fix in this area.

@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

https://gerrit.sqlalchemy.org/219

@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

downstream at https://review.openstack.org/#/c/389363/

@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

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

232eec4

@sqlalchemy-bot
Copy link
Collaborator Author

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

@sqlalchemy-bot sqlalchemy-bot added schema things related to the DDL related objects like Table, Column, CreateIndex, etc. bug Something isn't working labels Nov 27, 2018
@sqlalchemy-bot sqlalchemy-bot added this to the 1.1.x milestone Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working schema things related to the DDL related objects like Table, Column, CreateIndex, etc.
Projects
None yet
Development

No branches or pull requests

1 participant