changeset 4130:980f12d3c766 request_hist_bns

bottleneck import: Fixed detection of identical bottlenecks.
author Sascha Wilde <wilde@intevation.de>
date Thu, 01 Aug 2019 18:23:32 +0200
parents 24c5eec22c2d
children 49ec33a7f954
files pkg/imports/bn.go
diffstat 1 files changed, 10 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/imports/bn.go	Thu Aug 01 17:28:35 2019 +0200
+++ b/pkg/imports/bn.go	Thu Aug 01 18:23:32 2019 +0200
@@ -90,24 +90,23 @@
 RETURNING id
 `
 
+	// We only check for NOT NULL values, for correct compairison with
+	// values, which might be null (and then muyst not be compairt with `='
+	// but with `IS NULL' is comlicated and that we are checking more than
+	// only (bottleneck_id, validity, date_info) is luxury already.
 	findExactMatchBottleneckSQL = `
 WITH
-bounds (b) AS (VALUES (isrs_fromText($6)), (isrs_fromText($7))),
+bounds (b) AS (VALUES (isrs_fromText($4)), (isrs_fromText($5))),
 r AS (SELECT isrsrange(
-    (SELECT b FROM bounds ORDER BY b USING <~ FETCH FIRST ROW ONLY),
-    (SELECT b FROM bounds ORDER BY b USING >~ FETCH FIRST ROW ONLY)) AS r)
+      (SELECT b FROM bounds ORDER BY b USING <~ FETCH FIRST ROW ONLY),
+      (SELECT b FROM bounds ORDER BY b USING >~ FETCH FIRST ROW ONLY)) AS r)
 SELECT id FROM waterway.bottlenecks
 WHERE (
   bottleneck_id,
   validity,
   gauge_location,
-  objnam,
-  nobjnm,
   stretch,
-  rb,
-  lb,
   responsible_country,
-  revisiting_time,
   limiting,
   date_info,
   source_organization,
@@ -116,16 +115,11 @@
   $1,
   $2::tstzrange,
   isrs_fromText($3),
-  $4,
-  $5,
   (SELECT r FROM r),
-  $8,
+  $6,
+  $7,
+  $8::timestamptz,
   $9,
-  $10,
-  $11::smallint,
-  $12,
-  $13::timestamptz,
-  $14,
   true
 )
 `
@@ -465,13 +459,8 @@
 		bn.Bottleneck_id,
 		&validity,
 		bn.Fk_g_fid,
-		bn.OBJNAM,
-		bn.NOBJNM,
 		bn.From_ISRS, bn.To_ISRS,
-		rb,
-		lb,
 		country,
-		revisitingTime,
 		limiting,
 		bn.Date_Info,
 		bn.Source,