comparison pkg/imports/gm.go @ 3533:8e083b271fca

Improve error messages if no matching gauge version found Avoid hitting the NOT NULL constraint of the referencing validity column in order to hit the foreign key constraint instead and emit an appropriate error message in all such cases.
author Tom Gottfried <tom@intevation.de>
date Wed, 29 May 2019 18:14:20 +0200
parents ec6163c6687d
children d38b20ccb6f9
comparison
equal deleted inserted replaced
3530:e98ea184538e 3533:8e083b271fca
71 date_info, 71 date_info,
72 source_organization, 72 source_organization,
73 staging_done 73 staging_done
74 ) VALUES ( 74 ) VALUES (
75 ($1, $2, $3, $4, $5), 75 ($1, $2, $3, $4, $5),
76 (SELECT validity FROM waterway.gauges 76 COALESCE(
77 WHERE location 77 (SELECT validity FROM waterway.gauges
78 = ($1::char(2), $2::char(3), $3::char(5), $4::char(5), $5::int) 78 WHERE location
79 AND validity @> CAST($6 AS timestamp with time zone)), 79 = ($1::char(2), $2::char(3), $3::char(5), $4::char(5), $5::int)
80 AND validity @> CAST($6 AS timestamp with time zone)),
81 tstzrange(NULL, NULL)),
80 $6, 82 $6,
81 $7, 83 $7,
82 $8, 84 $8,
83 $9, 85 $9,
84 $10, 86 $10,
106 conf_interval, 108 conf_interval,
107 date_info, 109 date_info,
108 source_organization 110 source_organization
109 ) VALUES( 111 ) VALUES(
110 ($1, $2, $3, $4, $5), 112 ($1, $2, $3, $4, $5),
111 (SELECT validity FROM waterway.gauges 113 COALESCE(
112 WHERE location 114 (SELECT validity FROM waterway.gauges
113 = ($1::char(2), $2::char(3), $3::char(5), $4::char(5), $5::int) 115 WHERE location
114 AND validity @> CAST($6 AS timestamp with time zone)), 116 = ($1::char(2), $2::char(3), $3::char(5), $4::char(5), $5::int)
117 AND validity @> CAST($6 AS timestamp with time zone)),
118 tstzrange(NULL, NULL)),
115 $6, 119 $6,
116 $7, 120 $7,
117 $8, 121 $8,
118 $9, 122 $9,
119 $10, 123 $10,