mirror of
https://github.com/MeshCore-Beacon/beacon-server.git
synced 2026-10-23 22:42:54 +00:00
fix(seed): make UpsertIATADetails a true upsert
UpsertIATADetails was a plain UPDATE that silently affected zero rows when the iata_codes row did not yet exist. Adding a new IATA to the config for the first time resulted in display_name, approx_lat, and approx_lng remaining NULL. Change the query to INSERT ... ON CONFLICT DO UPDATE so the row is atomically created (if missing) or updated (if present), matching the function's name and the pattern used by UpsertTransportScope.
This commit is contained in:
1 parent
f143ff1b0a
commit
87239bd4b8
2 files changed
+12
-10
No files matched your search
@@ -17,11 +17,12 @@ SELECT * FROM iata_codes WHERE iata = $1;
|
||||
SELECT * FROM iata_codes ORDER BY iata;
|
||||
|
||||
-- name: UpsertIATADetails :exec
|
||||
UPDATE iata_codes SET
|
||||
display_name = $2,
|
||||
approx_lat = $3,
|
||||
approx_lng = $4
|
||||
WHERE iata = $1;
|
||||
INSERT INTO iata_codes (iata, display_name, approx_lat, approx_lng)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
ON CONFLICT (iata) DO UPDATE SET
|
||||
display_name = EXCLUDED.display_name,
|
||||
approx_lat = EXCLUDED.approx_lat,
|
||||
approx_lng = EXCLUDED.approx_lng;
|
||||
|
||||
-- ============================================================
|
||||
-- TRANSPORT CODES
|
||||
|
||||
Reference in new issue
Block a user