Skip to content
Browse files

[processing] Don't abort when missing field name specified in

delete columns algorithm

Fixes #19256
  • Loading branch information
nyalldawson committed Jun 26, 2018
1 parent 6f5405a commit 85fba799eaabfcd0d4da0177daa21dea1ff846aa
@@ -68,13 +68,22 @@ def outputName(self):

def prepareAlgorithm(self, parameters, context, feedback):
self.fields_to_delete = self.parameterAsFields(parameters, self.COLUMNS, context)
return True

source = self.parameterAsSource(parameters, 'INPUT', context)
if source is not None:
for f in self.fields_to_delete:
index = source.fields().lookupField(f)
if index < 0:
feedback.pushInfo('Field “{}” does not exist in input layer').format(f))

return super().prepareAlgorithm(parameters, context, feedback)

def outputFields(self, input_fields):
# loop through twice - first we need to build up a list of original attribute indices
for f in self.fields_to_delete:
index = input_fields.lookupField(f)
if index >= 0:

# important - make sure we remove from the end so we aren't changing used indices as we go
@@ -2143,7 +2143,7 @@ tests:
- algorithm: qgis:deletecolumn
name: Delete columns (multiple)
COLUMN: floatval;name
COLUMN: floatval;name;xxxxxx
name: polys.gml
type: vector

0 comments on commit 85fba79

Please sign in to comment.
You can’t perform that action at this time.