]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/db/sqlalchemy_types.py
make code work with Spatialite 4.3
[nominatim.git] / nominatim / db / sqlalchemy_types.py
index d1ff7635660b277b8bb276f53581180b8dd1367d..036b25dd9ac48e2500b4f31e8d7dcc6221bd38bf 100644 (file)
@@ -38,7 +38,7 @@ def _default_distance_spheroid(element: SaColumn,
 @compiles(Geometry_DistanceSpheroid, 'sqlite') # type: ignore[no-untyped-call, misc]
 def _spatialite_distance_spheroid(element: SaColumn,
                                   compiler: 'sa.Compiled', **kw: Any) -> str:
-    return "Distance(%s, true)" % compiler.process(element.clauses, **kw)
+    return "COALESCE(Distance(%s, true), 0.0)" % compiler.process(element.clauses, **kw)
 
 
 class Geometry_IsLineLike(sa.sql.expression.FunctionElement[bool]):