Commit a8085ed5 authored by Julien Cristau's avatar Julien Cristau
Browse files

accept SQLExpression in convert_geom

If we're passed an SQLExpression, leave it as-is, don't run
ST_GeomFromText.
parent dfa967d7dfce
......@@ -48,12 +48,13 @@ pghelper.TYPE_MAPPING['Geography'] = pg_geography_sqltype
# Add a converter for Geometry
def convert_geom(x):
if isinstance(x, SQLExpression):
return x
if isinstance(x, (tuple, list)):
# We give the (Geometry, SRID)
return SQLExpression('ST_GeomFromText(%(geo)s, %(srid)s)', geo=x[0], srid=x[1])
else:
# We just give the Geometry
return SQLExpression('ST_GeomFromText(%(geo)s, %(srid)s)', geo=x, srid=-1)
# We just give the Geometry
return SQLExpression('ST_GeomFromText(%(geo)s, %(srid)s)', geo=x, srid=-1)
def convert_geog(x):
# takes only a Geometry type, assumes GPS srid
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment