comparison pkg/imports/bn.go @ 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 14706384a464
children eb08fbe33074
comparison
equal deleted inserted replaced
4129:24c5eec22c2d 4130:980f12d3c766
88 $14 88 $14
89 ) 89 )
90 RETURNING id 90 RETURNING id
91 ` 91 `
92 92
93 // We only check for NOT NULL values, for correct compairison with
94 // values, which might be null (and then muyst not be compairt with `='
95 // but with `IS NULL' is comlicated and that we are checking more than
96 // only (bottleneck_id, validity, date_info) is luxury already.
93 findExactMatchBottleneckSQL = ` 97 findExactMatchBottleneckSQL = `
94 WITH 98 WITH
95 bounds (b) AS (VALUES (isrs_fromText($6)), (isrs_fromText($7))), 99 bounds (b) AS (VALUES (isrs_fromText($4)), (isrs_fromText($5))),
96 r AS (SELECT isrsrange( 100 r AS (SELECT isrsrange(
97 (SELECT b FROM bounds ORDER BY b USING <~ FETCH FIRST ROW ONLY), 101 (SELECT b FROM bounds ORDER BY b USING <~ FETCH FIRST ROW ONLY),
98 (SELECT b FROM bounds ORDER BY b USING >~ FETCH FIRST ROW ONLY)) AS r) 102 (SELECT b FROM bounds ORDER BY b USING >~ FETCH FIRST ROW ONLY)) AS r)
99 SELECT id FROM waterway.bottlenecks 103 SELECT id FROM waterway.bottlenecks
100 WHERE ( 104 WHERE (
101 bottleneck_id, 105 bottleneck_id,
102 validity, 106 validity,
103 gauge_location, 107 gauge_location,
104 objnam,
105 nobjnm,
106 stretch, 108 stretch,
107 rb,
108 lb,
109 responsible_country, 109 responsible_country,
110 revisiting_time,
111 limiting, 110 limiting,
112 date_info, 111 date_info,
113 source_organization, 112 source_organization,
114 staging_done 113 staging_done
115 ) = ( SELECT 114 ) = ( SELECT
116 $1, 115 $1,
117 $2::tstzrange, 116 $2::tstzrange,
118 isrs_fromText($3), 117 isrs_fromText($3),
119 $4,
120 $5,
121 (SELECT r FROM r), 118 (SELECT r FROM r),
122 $8, 119 $6,
120 $7,
121 $8::timestamptz,
123 $9, 122 $9,
124 $10,
125 $11::smallint,
126 $12,
127 $13::timestamptz,
128 $14,
129 true 123 true
130 ) 124 )
131 ` 125 `
132 126
133 findIntersectingBottleneckSQL = ` 127 findIntersectingBottleneckSQL = `
463 err := tx.StmtContext(ctx, bs.findExactMatch).QueryRowContext( 457 err := tx.StmtContext(ctx, bs.findExactMatch).QueryRowContext(
464 ctx, 458 ctx,
465 bn.Bottleneck_id, 459 bn.Bottleneck_id,
466 &validity, 460 &validity,
467 bn.Fk_g_fid, 461 bn.Fk_g_fid,
468 bn.OBJNAM,
469 bn.NOBJNM,
470 bn.From_ISRS, bn.To_ISRS, 462 bn.From_ISRS, bn.To_ISRS,
471 rb,
472 lb,
473 country, 463 country,
474 revisitingTime,
475 limiting, 464 limiting,
476 bn.Date_Info, 465 bn.Date_Info,
477 bn.Source, 466 bn.Source,
478 ).Scan(&old) 467 ).Scan(&old)
479 switch { 468 switch {