[PATCH] Do not rely on database default for setting hws_lines.official to 0
Wald Commits
scm-commit at wald.intevation.org
Fri Mar 12 15:16:53 CET 2021
# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1615558304 -3600
# Fri Mar 12 15:11:44 2021 +0100
# Branch 3.2.x
# Node ID aef9871248220afc380575748e6322a3e7369281
# Parent b880a8adc2b22d784fe04d31e06813ef6094ba90
Do not rely on database default for setting hws_lines.official to 0
It's not under the control of the importer whether the field is rendered
into an INSERT statement, whether it's actually set or not. If it is
unset but rendered into the statement, the field would be set to NULL.
Thus, always set it explicitly.
While here, remove an unused import.
diff -r b880a8adc2b2 -r aef987124822 backend/contrib/shpimporter/hws.py
--- a/backend/contrib/shpimporter/hws.py Thu Mar 04 13:05:19 2021 +0100
+++ b/backend/contrib/shpimporter/hws.py Fri Mar 12 15:11:44 2021 +0100
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
-import os
-
try:
from osgeo import ogr
except ImportError:
@@ -162,18 +160,18 @@
if not self.IsFieldSet(feat, fname):
newFeat.SetField("name", args['name'])
+ official = False
fname = self.searchField("offiziell$")
if self.IsFieldSet(feat, fname):
self.handled(fname)
offiziell = feat.GetField(fname)
if offiziell == "1" or offiziell == 1:
- newFeat.SetField("official", True)
+ official = True
# Set the official value based on the file name as a fallback
elif args.get("name", "").lower() == "rohre_und_sperren" or \
args.get("name", "").lower() == "rohre-und-sperren":
- newFeat.SetField("official", True)
- else:
- newFeat.SetField("official", False)
+ official = True
+ newFeat.SetField("official", official)
if self.IsFieldSet(newFeat, "z") and \
self.IsFieldSet(newFeat, "rated_level"):
More information about the Dive4Elements-commits
mailing list