]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/api/reverse.py
use string representation when dumping variables
[nominatim.git] / nominatim / api / reverse.py
index ccd1758cf345b8d0c7ffbbd593e377440aaf092c..10c97cad221702e513d175c339bf9db46e73a148 100644 (file)
@@ -235,7 +235,7 @@ class ReverseGeocoder:
         if parent_place_id is not None:
             sql = sql.where(t.c.parent_place_id == parent_place_id)
 
-        inner = sql.subquery()
+        inner = sql.subquery('ipol')
 
         sql = sa.select(inner.c.place_id, inner.c.osm_id,
                         inner.c.parent_place_id, inner.c.address,
@@ -245,8 +245,8 @@ class ReverseGeocoder:
                         inner.c.distance)
 
         if self.has_geometries():
-            sub = sql.subquery()
-            sql = self._add_geometry_columns(sql, sub.c.centroid)
+            sub = sql.subquery('geom')
+            sql = self._add_geometry_columns(sa.select(sub), sub.c.centroid)
 
         return (await self.conn.execute(sql)).one_or_none()
 
@@ -263,7 +263,7 @@ class ReverseGeocoder:
                   .where(t.c.parent_place_id == parent_place_id)\
                   .order_by('distance')\
                   .limit(1)\
-                  .subquery()
+                  .subquery('tiger')
 
         sql = sa.select(inner.c.place_id,
                         inner.c.parent_place_id,
@@ -275,8 +275,8 @@ class ReverseGeocoder:
                         inner.c.distance)
 
         if self.has_geometries():
-            sub = sql.subquery()
-            sql = self._add_geometry_columns(sql, sub.c.centroid)
+            sub = sql.subquery('geom')
+            sql = self._add_geometry_columns(sa.select(sub), sub.c.centroid)
 
         return (await self.conn.execute(sql)).one_or_none()
 
@@ -356,7 +356,7 @@ class ReverseGeocoder:
                   .where(t.c.type != 'postcode')\
                   .order_by(sa.desc(t.c.rank_search))\
                   .limit(50)\
-                  .subquery()
+                  .subquery('area')
 
         sql = _select_from_placex(inner)\
                   .where(inner.c.geometry.ST_Contains(wkt))\
@@ -385,7 +385,7 @@ class ReverseGeocoder:
                                 .intersects(wkt))\
                       .order_by(sa.desc(t.c.rank_search))\
                       .limit(50)\
-                      .subquery()
+                      .subquery('places')
 
             touter = self.conn.t.placex.alias('outer')
             sql = _select_from_placex(inner)\
@@ -548,6 +548,6 @@ class ReverseGeocoder:
             result.distance = row.distance
             if hasattr(row, 'bbox'):
                 result.bbox = Bbox.from_wkb(row.bbox.data)
-            await nres.add_result_details(self.conn, result, self.params)
+            await nres.add_result_details(self.conn, [result], self.params)
 
         return result