You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#73 adds support for detecting postgrersql SERIAL, so alembic won't take nextval(some sequence) as server default for column of serial type in autogenerate. But it doesn't take effect with table not under search path.
Expected behavior
The result of autogererate should not contain server default for column id.
To Reproduce
Run the code below with an empty dataabse.
importsqlalchemyassafromalembic.autogenerate.apiimportproduce_migrationsfromalembic.autogenerate.apiimportrender_python_codefromalembic.migrationimportMigrationContextengine=sa.create_engine("postgresql://name:pass@host:1234/tmp")
withengine.connect() asconn, conn.begin():
conn.execute(sa.text(
""" CREATE SCHEMA IF NOT EXISTS test; DROP TABLE IF EXISTS test.account; CREATE TABLE test.account(id SERIAL PRIMARY KEY); """
))
metadata=sa.MetaData(schema="test")
mc=MigrationContext.configure(
connection=engine.connect(),
opts={"include_schemas": "test"}
)
migration_script=produce_migrations(mc, metadata)
downgrade_code=render_python_code(migration_script.downgrade_ops)
print(downgrade_code)
Error
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('account',
sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('test.account_id_seq'::regclass)"), autoincrement=True, nullable=False),
sa.PrimaryKeyConstraint('id', name='account_pkey'),
schema='test'
)
# ### end Alembic commands ###
Versions.
OS: macos 12.6.3
Python: 3.10.9
Alembic: 1.13.1
SQLAlchemy: 2.0.30
Database: PostgreSQL 13.14
DBAPI: psycopg2-binary 2.9.9
Additional context
In the column reflect function, it tries to check the relation of sequence between table by sequence name. The seqname contains schema info, while pgclass's relname not. Maybe should cast sequence name to regclass and filter by pgclass.oid?
Have a nice day!
The text was updated successfully, but these errors were encountered:
Describe the bug
#73 adds support for detecting postgrersql SERIAL, so alembic won't take
nextval(some sequence)
as server default for column of serial type in autogenerate. But it doesn't take effect with table not under search path.Expected behavior
The result of autogererate should not contain server default for column id.
To Reproduce
Run the code below with an empty dataabse.
Error
Versions.
Additional context
In the column reflect function, it tries to check the relation of sequence between table by sequence name. The
seqname
contains schema info, whilepgclass
's relname not. Maybe should cast sequence name to regclass and filter bypgclass.oid
?Have a nice day!
The text was updated successfully, but these errors were encountered: