Skip to content

Commit

Permalink
Use 'load_dialect_impl()' instead of 'impl' to get the type of the Ty…
Browse files Browse the repository at this point in the history
…peDecorator objects (#346)
  • Loading branch information
adrien-berchet committed Jan 7, 2022
1 parent 7fa9295 commit 9a69732
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions geoalchemy2/__init__.py
Expand Up @@ -32,12 +32,12 @@ def _format_select_args(*args):
return args


def _check_spatial_type(tested_type, spatial_types):
def _check_spatial_type(tested_type, spatial_types, dialect):
return (
isinstance(tested_type, spatial_types)
or (
isinstance(tested_type, TypeDecorator)
and isinstance(tested_type.impl, spatial_types)
and isinstance(tested_type.load_dialect_impl(dialect), spatial_types)
)
)

Expand All @@ -64,7 +64,7 @@ def dispatch(event, table, bind):
# Filter Geometry columns from the table with management=True
# Note: Geography and PostGIS >= 2.0 don't need this
gis_cols = [c for c in table.c if
_check_spatial_type(c.type, Geometry)
_check_spatial_type(c.type, Geometry, bind.dialect)
and c.type.management is True]

# Find all other columns that are not managed Geometries
Expand Down Expand Up @@ -103,7 +103,7 @@ def dispatch(event, table, bind):
for c in table.c:
# Add the managed Geometry columns with AddGeometryColumn()
if (
_check_spatial_type(c.type, Geometry)
_check_spatial_type(c.type, Geometry, bind.dialect)
and c.type.management is True
):
args = [table.schema] if table.schema else []
Expand All @@ -125,7 +125,7 @@ def dispatch(event, table, bind):

# Add spatial indices for the Geometry and Geography columns
if (
_check_spatial_type(c.type, (Geometry, Geography))
_check_spatial_type(c.type, (Geometry, Geography), bind.dialect)
and c.type.spatial_index is True
):
if bind.dialect.name == 'sqlite':
Expand Down

0 comments on commit 9a69732

Please sign in to comment.