fix(gisogd66): CAST(:geojson AS text) — AmbiguousParameter ронял каждый upsert (#2383)
All checks were successful
Deploy / changes (push) Successful in 7s
Deploy / build-frontend (push) Has been skipped
Deploy / build-backend (push) Successful in 2m4s
Deploy / build-worker (push) Successful in 3m46s
Deploy / deploy (push) Successful in 1m44s

This commit is contained in:
bot-backend 2026-07-04 06:55:18 +00:00
parent 9850bbde14
commit 4f0cae5c18

View file

@ -277,8 +277,12 @@ def _upsert_permit(db: Session, rec: dict[str, Any]) -> str:
:doc_group, :doc_num, :doc_name, :date_doc, :date_reg,
:approved_org, :source_schema, :source_key,
CAST(:cad_nums AS text[]),
CASE WHEN :geojson IS NULL THEN NULL
ELSE ST_Multi(ST_SetSRID(ST_GeomFromGeoJSON(:geojson), 4326)) END,
-- CAST обязателен: без него ни одно вхождение :geojson не даёт Postgres
-- тип параметра (ST_GeomFromGeoJSON перегружена text/json/jsonb)
-- psycopg.errors.AmbiguousParameter на КАЖДОЙ строке (прод-прогон #2367).
CASE WHEN CAST(:geojson AS text) IS NULL THEN NULL
ELSE ST_Multi(ST_SetSRID(
ST_GeomFromGeoJSON(CAST(:geojson AS text)), 4326)) END,
NOW(), NOW()
)
ON CONFLICT (doc_group, doc_num) DO UPDATE