From 6dfff5e0465a4a1fd6e05557bb0f5185f48a0e6b Mon Sep 17 00:00:00 2001 From: lekss361 <47113017+lekss361@users.noreply.github.com> Date: Fri, 15 May 2026 16:02:03 +0300 Subject: [PATCH] =?UTF-8?q?fix(cadastre):=20CAST=20:geom=20AS=20text=20?= =?UTF-8?q?=E2=80=94=20psycopg=20AmbiguousParameter=20(#168)=20(#178)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: lekss361 --- backend/app/services/cadastre/bulk_harvest.py | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/backend/app/services/cadastre/bulk_harvest.py b/backend/app/services/cadastre/bulk_harvest.py index 55c60fec..f839c70a 100644 --- a/backend/app/services/cadastre/bulk_harvest.py +++ b/backend/app/services/cadastre/bulk_harvest.py @@ -358,9 +358,9 @@ def upsert_parcel(db: Session, feature: NSPDBulkFeature, source: str = "search") :readable_address, :status, :previously_posted, CAST(:registration_date AS date), :subcategory, :cadastral_districts_code, - CASE WHEN :geom IS NOT NULL THEN + CASE WHEN CAST(:geom AS text) IS NOT NULL THEN ST_Transform( - ST_SetSRID(ST_GeomFromGeoJSON(:geom), 3857), + ST_SetSRID(ST_GeomFromGeoJSON(CAST(:geom AS text)), 3857), 4326 ) ELSE NULL END, @@ -471,9 +471,9 @@ def upsert_building(db: Session, feature: NSPDBulkFeature, source: str = "search :cultural_heritage_object, :cultural_heritage_val, :readable_address, :status, :common_data_status, :type, :build_record_type_value, - CASE WHEN :geom IS NOT NULL THEN + CASE WHEN CAST(:geom AS text) IS NOT NULL THEN ST_Transform( - ST_SetSRID(ST_GeomFromGeoJSON(:geom), 3857), + ST_SetSRID(ST_GeomFromGeoJSON(CAST(:geom AS text)), 3857), 4326 ) ELSE NULL END, @@ -593,8 +593,8 @@ def upsert_construction(db: Session, feature: NSPDBulkFeature, source: str = "se :readable_address, :address_readable_address, :status, :common_data_status, CAST(:registration_date AS date), :registers_id, :united_cad_number, - CASE WHEN :geom IS NOT NULL THEN - ST_Transform(ST_SetSRID(ST_GeomFromGeoJSON(:geom), 3857), 4326) + CASE WHEN CAST(:geom AS text) IS NOT NULL THEN + ST_Transform(ST_SetSRID(ST_GeomFromGeoJSON(CAST(:geom AS text)), 3857), 4326) ELSE NULL END, CAST(:raw_props AS jsonb), :source, NOW(), NOW() ) @@ -689,8 +689,8 @@ def upsert_onc(db: Session, feature: NSPDBulkFeature, source: str = "search") -> :cad_num, :quarter_cad_number, :purpose, :area, :build_record_area, :cost_value, :status, :readable_address, - CASE WHEN :geom IS NOT NULL THEN - ST_Transform(ST_SetSRID(ST_GeomFromGeoJSON(:geom), 3857), 4326) + CASE WHEN CAST(:geom AS text) IS NOT NULL THEN + ST_Transform(ST_SetSRID(ST_GeomFromGeoJSON(CAST(:geom AS text)), 3857), 4326) ELSE NULL END, CAST(:raw_props AS jsonb), :source, NOW(), NOW() ) @@ -750,8 +750,8 @@ def upsert_enk(db: Session, feature: NSPDBulkFeature, source: str = "search") -> :name, :purpose, :type, :cost_value, :facility_cad_number, :readable_address, CAST(:registration_date AS date), :registers_id, - CASE WHEN :geom IS NOT NULL THEN - ST_Transform(ST_SetSRID(ST_GeomFromGeoJSON(:geom), 3857), 4326) + CASE WHEN CAST(:geom AS text) IS NOT NULL THEN + ST_Transform(ST_SetSRID(ST_GeomFromGeoJSON(CAST(:geom AS text)), 3857), 4326) ELSE NULL END, CAST(:raw_props AS jsonb), NOW(), NOW() ) @@ -828,9 +828,12 @@ def upsert_zouit(db: Session, feature: NSPDBulkFeature, source: str = "search") :legal_act_name, CAST(:legal_act_date AS date), :legal_act_number, :legal_act_issuer, CAST(:registration_date AS date), :old_account_number, - CASE WHEN :geom IS NOT NULL THEN + CASE WHEN CAST(:geom AS text) IS NOT NULL THEN ST_Multi( - ST_Transform(ST_SetSRID(ST_GeomFromGeoJSON(:geom), 3857), 4326) + ST_Transform( + ST_SetSRID(ST_GeomFromGeoJSON(CAST(:geom AS text)), 3857), + 4326, + ) ) ELSE NULL END, CAST(:raw_props AS jsonb), :source, NOW(), NOW()