mirror of
https://github.com/MeshCore-Beacon/beacon-server.git
synced 2026-09-01 16:48:19 +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:
@@ -3025,11 +3025,12 @@ func (q *Queries) UpsertIATA(ctx context.Context, iata string) error {
|
||||
}
|
||||
|
||||
const upsertIATADetails = `-- 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
|
||||
`
|
||||
|
||||
type UpsertIATADetailsParams struct {
|
||||
|
||||
Reference in New Issue
Block a user