Skip to content

Commit

Permalink
fixes for the latest alembic
Browse files Browse the repository at this point in the history
  • Loading branch information
daimor committed May 18, 2023
1 parent de12509 commit e0ccd4b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 13 additions & 7 deletions sqlalchemy_iris/alembic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import re

from typing import Optional
from typing import Any
Expand Down Expand Up @@ -67,12 +68,17 @@ def compare_server_default(
):
return False

return super().compare_server_default(
inspector_column,
metadata_column,
rendered_metadata_default,
rendered_inspector_default,
)
if rendered_metadata_default is not None:
rendered_metadata_default = re.sub(
r"[\(\) \"\']", "", rendered_metadata_default
)

if rendered_inspector_default is not None:
rendered_inspector_default = re.sub(
r"[\(\) \"\']", "", rendered_inspector_default
)

return rendered_inspector_default != rendered_metadata_default

def alter_column(
self,
Expand Down Expand Up @@ -178,10 +184,10 @@ def visit_rename_column(element: ColumnName, compiler: IRISDDLCompiler, **kw) ->
format_column_name(compiler, element.newname),
)


@compiles(DropColumn, "iris")
def visit_drop_column(element: DropColumn, compiler: IRISDDLCompiler, **kw) -> str:
return "%s %s CASCADE" % (
alter_table(compiler, element.table_name, element.schema),
drop_column(compiler, element.column.name, **kw),
)

2 changes: 1 addition & 1 deletion tests/test_alembic.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def tables(self, connection):
self.meta.drop_all(connection)

def test_drop_col_with_fk(self, ops_context, connection, tables):
ops_context.drop_column("round_trip_table", "oid_fk", self.meta.schema)
ops_context.drop_column("round_trip_table", "oid_fk", schema=self.meta.schema)
insp = inspect(connection)
eq_(insp.get_foreign_keys("round_trip_table", schema=self.meta.schema), [])

Expand Down

0 comments on commit e0ccd4b

Please sign in to comment.