Skip to content

Migration autogeneration should respect schemas defined using quoted_name #1526

Open
@characat0

Description

@characat0

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!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions