Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[processing] Don't abort when missing field name specified in
delete columns algorithm
Fixes #19256
(cherry-picked from 85fba79)
- Loading branch information
|
@@ -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(self.tr('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) |
|
|
self.field_indices.append(index) |
|
|
if index >= 0: |
|
|
self.field_indices.append(index) |
|
|
|
|
|
# important - make sure we remove from the end so we aren't changing used indices as we go |
|
|
self.field_indices.sort(reverse=True) |
|
|
|
@@ -2143,7 +2143,7 @@ tests: |
|
|
- algorithm: qgis:deletecolumn |
|
|
name: Delete columns (multiple) |
|
|
params: |
|
|
COLUMN: floatval;name |
|
|
COLUMN: floatval;name;xxxxxx |
|
|
INPUT: |
|
|
name: polys.gml |
|
|
type: vector |
|
|