I have a Peewee model that has a custom Geometry field, much like standard examples found online. The geometry field puts data into mysql using:
def db_value(self, value):
return fn.ST_GeomFromGeoJSON(value)
This seems to work, I can retrieve this data using:
SELECT id,ST_AsGeoJSON(geom) AS other FROM geomTable
Or a select query in peewee:
geomTable.select(geomTable.id,fn.ST_AsGeoJSON(geomTable.geom))
However if I attempt to retrieve it using a function in the geometry field such as:
def python_value(self, value):
return fn.ST_AsGeoJSON(value)
It returns a peewee.Function object rather than the geojson. In fact, the generated sql using python_value doesn't even include ST_AsGeoJSON, as it does when I use a standalone select. Any guidance would be appreciated!