Mercurial > gemma
diff 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 |
line wrap: on
line diff
--- a/pkg/imports/wg.go Fri May 24 15:32:47 2019 +0200 +++ b/pkg/imports/wg.go Fri May 24 17:45:17 2019 +0200 @@ -235,6 +235,13 @@ gauges = append(gauges, isrs) feedback.Info("Processing %s", code) + // We need a valid time range to identify gauge versions in DB + if time.Time(*dr.Enddate).Before(time.Time(*dr.Startdate)) { + feedback.Warn("End date before start date. Ignored") + unchanged++ + continue + } + var from, to sql.NullInt64 if dr.Applicabilityfromkm != nil {