Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

custom include_name() affect reflection, making it always include all tables all time #1268

Closed
wasdee opened this issue Jul 8, 2023 · 1 comment

Comments

@wasdee
Copy link

wasdee commented Jul 8, 2023

reflection

Describe the bug

def include_name(name, type_, parent_names):
    debug(name, type_, parent_names)
    if type_ == "schema":
        return name in ["public"]
    else:
        return True

in online migration, the adding include_name() to

def do_run_migrations(connection: Connection) -> None:
    ""
    Run actual sync migrations.

    :param connection: connection to the database.
    """
    context.configure(
        connection=connection,
        target_metadata=target_metadata,
        include_schemas=True,
        include_name=include_name,
    )

    with context.begin_transaction():
        context.run_migrations()

make it fail to exclude the existing table for the auto generate sciprt alembic revision --autogenerate

removing it thing will work properly

Expected behavior

added include_name() should not effect the correctness of diff

To Reproduce
Please try to provide a Minimal, Complete, and Verifiable example, with the migration script and/or the SQLAlchemy tables or models involved.
See also Reporting Bugs on the website.

Available upon request, I cannot post code/stack trace publicly. i need to spend some amount of time to recreate reproduce env for you.
I hope this issue could easily recreate by you, if not let me know

Error

There is no error. on console

Versions.

  • OS: Ubuntu 22 WSL2
  • Python: python 3.10
  • Alembic: alembic 1.11.1
  • SQLAlchemy: '2.0.18'
  • Database: postgis, FROM postgis/postgis:14-3.3
  • DBAPI: "postgresql+asyncpg"

Additional context

I'm using PostGIS. the it has some auxeraly tables that they would always drop if i not add include_name to filter out.

Have a nice day!

@wasdee wasdee added the requires triage New issue that requires categorization label Jul 8, 2023
@wasdee
Copy link
Author

wasdee commented Jul 8, 2023

workaround

for my case

from geoalchemy2 import alembic_helpers

def include_object(object, name, type_, reflected, compare_to):
    if type_ == "table" and object.schema != "public":
        return False

    return alembic_helpers.include_object(object, name, type_, reflected, compare_to)

@sqlalchemy sqlalchemy locked and limited conversation to collaborators Jul 8, 2023
@zzzeek zzzeek converted this issue into discussion #1269 Jul 8, 2023
@zzzeek zzzeek added autogenerate - detection and removed requires triage New issue that requires categorization labels Jul 8, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

2 participants