sqlalchemy / sqlalchemy/alembic
Migration autogeneration should respect schemas defined using quoted_name
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 375
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
When defining a table, schemas defined using quoted_name should be present on the migration generated code.
Expected behavior
The schema present in the migration file should be defined using quoted_name too
To Reproduce
Define a class using the snipped provided, then run alembic revision --autogenerate and check the generated migration operations
from sqlalchemy.orm import DeclarativeBase
from sqlalchemy import quoted_name
class Base(DeclarativeBase):
pass
class Example(Base):
__table_args__ = {'schema': quoted_name('database.schema', quote=False)}
example_field = Column(Integer, primary_key=True)
Actual behaviour
op.create_table('example',
sa.Column('example_field', sa.Integer()),
sa.PrimaryKeyConstraint('account_id'),
schema='database.schema'
)
Expected behaviour
op.create_table('example',
sa.Column('example_field', sa.Integer()),
sa.PrimaryKeyConstraint('account_id'),
schema=quoted_name('database.schema', quote=False)
)
Versions.
- OS: Mac
- Python:3.12
- Alembic: 1.13.2
- SQLAlchemy: 2.0.32
- Database: Databricks
Additional context
Im using the databricks sql connector 3.3.0
Have a nice day!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided DeclarativeBase and quoted_name example, then run alembic revision --autogenerate and inspect the generated migration operations. Trace the autogeneration path that renders the table schema; done means the generated migration preserves quoted_name('database.schema', quote=False) rather than emitting a plain string.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlalchemy
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100