fix(cadastre): CAST :geom AS text — psycopg AmbiguousParameter (#168) (#178)

Co-authored-by: lekss361 <claudestars@proton.me>
This commit is contained in:
lekss361 2026-05-15 16:02:03 +03:00 committed by GitHub
parent 99e2210919
commit 6dfff5e046
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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()