Skip to content

Commit

Permalink
Fix compatibility with Alembic>1.11 (#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-berchet authored May 17, 2023
1 parent fd3fce0 commit c9290c6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
25 changes: 15 additions & 10 deletions geoalchemy2/alembic_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def add_geo_column(context, revision, op):
if isinstance(col_type, (Geometry, Geography, Raster)):
op.column.type.spatial_index = False
op.column.type._spatial_index_reflected = None
new_op = AddGeospatialColumnOp(op.table_name, op.column, op.schema)
new_op = AddGeospatialColumnOp(op.table_name, op.column, schema=op.schema)
else:
new_op = op
return new_op
Expand All @@ -321,7 +321,7 @@ def drop_geo_column(context, revision, op):
dialect = context.bind.dialect
col_type = col_type.load_dialect_impl(dialect)
if isinstance(col_type, (Geometry, Geography, Raster)):
new_op = DropGeospatialColumnOp(op.table_name, op.column_name, op.schema)
new_op = DropGeospatialColumnOp(op.table_name, op.column_name, schema=op.schema)
else:
new_op = op
return new_op
Expand Down Expand Up @@ -425,7 +425,7 @@ def drop_geospatial_table(operations, operation):

if dialect.name == "sqlite":
_SPATIAL_TABLES.add(table_name)
operations.drop_table(table_name, operation.schema, **operation.table_kw)
operations.drop_table(table_name, schema=operation.schema, **operation.table_kw)


@renderers.dispatch_for(CreateGeospatialTableOp)
Expand All @@ -452,9 +452,9 @@ def create_geo_table(context, revision, op):
new_op = CreateGeospatialTableOp(
op.table_name,
op.columns,
op.schema,
op._namespace_metadata,
op._constraints_included,
schema=op.schema,
_namespace_metadata=op._namespace_metadata,
_constraints_included=op._constraints_included,
)
else:
new_op = op
Expand All @@ -472,7 +472,7 @@ def drop_geo_table(context, revision, op):
)

if gis_cols:
new_op = DropGeospatialTableOp(op.table_name, op.schema)
new_op = DropGeospatialTableOp(op.table_name, schema=op.schema)
else:
new_op = op

Expand Down Expand Up @@ -546,7 +546,7 @@ def drop_geospatial_index(
"""Handle the different situations arising from dropping geospatial index from a DB."""
op = cls(
index_name,
table_name,
table_name=table_name,
column_name=column_name,
schema=schema,
unique=unique,
Expand Down Expand Up @@ -668,7 +668,12 @@ def create_geo_index(context, revision, op):
op.kw["postgresql_ops"] = op.kw.get("postgresql_ops", postgresql_ops)

return CreateGeospatialIndexOp(
op.index_name, op.table_name, op.columns, op.schema, op.unique, **op.kw
op.index_name,
op.table_name,
op.columns,
schema=op.schema,
unique=op.unique,
**op.kw,
)

return op
Expand All @@ -687,7 +692,7 @@ def drop_geo_index(context, revision, op):
):
return DropGeospatialIndexOp(
op.index_name,
op.table_name,
table_name=op.table_name,
column_name=col.name,
schema=op.schema,
**op.kw,
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ deps=
alembic
sqla14: SQLAlchemy==1.4.*
sqlalatest: SQLAlchemy
sqla14: Alembic==1.10.*
sqlalatest: Alembic
!pypy3: psycopg2
pypy3: psycopg2cffi
!pypy3: Shapely>=1.3.0
Expand Down

0 comments on commit c9290c6

Please sign in to comment.