comparison pkg/imports/wg.go @ 3458:aa3c83fb7018

Validate temporal validity of gauges on import Since we need the time range to identify gauge versions in the WHERE-clause of the first statement, validate before it touches the database to avoid a quite unspecific error due to invalid range input.
author Tom Gottfried <tom@intevation.de>
date Fri, 24 May 2019 17:45:17 +0200
parents c04b1409a596
children de02dae6f7a8
comparison
equal deleted inserted replaced
3457:870812d8f247 3458:aa3c83fb7018
232 feedback.Warn("Invalid ISRS code '%s': %v", isrs, err) 232 feedback.Warn("Invalid ISRS code '%s': %v", isrs, err)
233 continue 233 continue
234 } 234 }
235 gauges = append(gauges, isrs) 235 gauges = append(gauges, isrs)
236 feedback.Info("Processing %s", code) 236 feedback.Info("Processing %s", code)
237
238 // We need a valid time range to identify gauge versions in DB
239 if time.Time(*dr.Enddate).Before(time.Time(*dr.Startdate)) {
240 feedback.Warn("End date before start date. Ignored")
241 unchanged++
242 continue
243 }
237 244
238 var from, to sql.NullInt64 245 var from, to sql.NullInt64
239 246
240 if dr.Applicabilityfromkm != nil { 247 if dr.Applicabilityfromkm != nil {
241 from = sql.NullInt64{ 248 from = sql.NullInt64{