diff options
Diffstat (limited to 'webmap-cgi')
-rwxr-xr-x | webmap-cgi | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -23,7 +23,7 @@ import sys from os import path as os_path -from json import load as json_load, dumps as json_dumps, JSONDecodeError +from json import load as json_load, JSONDecodeError import logging from typing import Final, Iterator import atexit @@ -163,10 +163,7 @@ def get_query_map(layernames : set[str]) -> dict[str,bytes]: query += common.escape_identifier(layername) + ' m ' query += 'WHERE m.' + common.escape_identifier(pkey_col) + ' = %s' query += ') ' - # TODO[trixie] use json_serialize() from PostgreSQL 17 to avoid serializing on - # the Python side. (There is also row_to_json() which might be of interest if - # json not jsonb is needed.) - query += 'SELECT to_jsonb(feature) FROM feature' + query += 'SELECT json_serialize(to_json(feature) RETURNING bytea) FROM feature' # The query never returns more than one row since we filter on a single FID. # TODO: batch queries using ANY[] or an IN set (the # consummer will then need # to re-order the response) @@ -237,7 +234,7 @@ def application(env, start_response) -> Iterator[bytes]: first = False else: yield b',' - yield json_dumps(resp[0], ensure_ascii=False, separators=(',', ':')).encode('utf-8') + yield resp[0] # the query never returns more than one row since we filter on a single FID if first: yield b'[]' # no match, empty response |