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 |
There was a problem hiding this comment.
Do you know why this isn't pulled in by subclassing the PostgresalImpl?
There was a problem hiding this comment.
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.
@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.
well Redshift should have an alembic impl called RedshiftImpl and use __dialect__ = 'redshift', subclassing PostgresqlImpl
There was a problem hiding this comment.
so you have that....and....@compiles(RenameTable, 'redshift') should do the individual elements
There was a problem hiding this comment.
Ah, so there's no nice way to automatically inherit the @compiles declarations
There was a problem hiding this comment.
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"