move search to bind parameters

This commit is contained in:
Sarah Hoffmann
2023-06-26 15:56:10 +02:00
parent 6c4c9ec1f2
commit 9f6f12cfeb
6 changed files with 117 additions and 88 deletions

View File

@@ -30,8 +30,10 @@ class Geometry(types.UserDefinedType[Any]):
def bind_processor(self, dialect: sa.Dialect) -> Callable[[Any], str]:
def process(value: Any) -> str:
assert isinstance(value, str)
return value
if isinstance(value, str):
return 'SRID=4326;' + value
return 'SRID=4326;' + value.to_wkt()
return process
@@ -84,6 +86,10 @@ class Geometry(types.UserDefinedType[Any]):
return sa.func.ST_Expand(self, other, type_=Geometry)
def ST_Collect(self) -> SaColumn:
return sa.func.ST_Collect(self, type_=Geometry)
def ST_Centroid(self) -> SaColumn:
return sa.func.ST_Centroid(self, type_=Geometry)