-
Notifications
You must be signed in to change notification settings - Fork 155
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
Compile Alembic's RenameTable the Postgres way #7
Compile Alembic's RenameTable the Postgres way #7
Conversation
Nice, but what did this compile as before? Edit: ah it's in your PR description |
I put it in the description: ALTER TABLE scheme."old" RENAME TO scheme."new" Note the scheme that's included in the TO, which Postgres doesn't support |
@@ -12,6 +12,9 @@ | |||
except ImportError: | |||
pass | |||
else: | |||
from alembic.ddl.base import RenameTable | |||
compiles(RenameTable, 'redshift')(postgresql.visit_rename_table) | |||
|
|||
class RedshiftImpl(postgresql.PostgresqlImpl): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know why this isn't pulled in by subclassing the PostgresalImpl?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because sqlalchemy uses the value in __dialect__
, which RedshiftImpl overrides
This is where alembic defines the postgres override: https://github.com/zzzeek/alembic/blob/eb077a6c8d2c468736ba537eb1ab5400c9059aad/alembic/ddl/postgresql.py#L124
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zzzeek do you know the best way to inherit dialects' "compiles" declarations?
Eg in a way that if more are added I don't have to keep updating my subclass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well Redshift should have an alembic impl called RedshiftImpl and use __dialect__ = 'redshift'
, subclassing PostgresqlImpl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so you have that....and....@compiles(RenameTable, 'redshift') should do the individual elements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, so there's no nice way to automatically inherit the @compiles declarations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right so why not subclassing. well @compiles someday might want to take into account the hierarchy of SQLCompiler subclasses. not really sure. redshift is a very odd case.
ee8d8f5
to
b99b8c3
Compare
Compile Alembic's RenameTable the Postgres way
…perly Compile Alembic's RenameTable the Postgres way
@graingert this fixes an issue where RenameTable would be compiled as
ALTER TABLE scheme."old" RENAME TO scheme."new"