Bug report #17170
Refactor fields processing algorithm missing expression context when edited in a model
Status: | Closed | ||
---|---|---|---|
Priority: | High | ||
Assignee: | - | ||
Category: | Processing/Modeller | ||
Affected QGIS version: | 2.18.13 | Regression?: | No |
Operating System: | Easy fix?: | No | |
Pull Request or Patch supplied: | No | Resolution: | |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 25069 |
Description
The "refactor fields" algorithm allows to create new fields based on an expression.
While this works fine, when started as a separate algorithm from the processing toolbox, the same expressions fail, when edited the "refactor fields" parameters as part of a model. The expression builder always reports an expression that involves an attribute field as "invalid syntax" and thus the expression can't be applied.
Somehow, when editing a model, some expression (layer) context is missing. In the expression builder, all fields of the chosen layer are missing.
Associated revisions
[processing] Allow QgsVectorLayerSelectedFeatureSource to
create expression context scopes
Allows algorithms which require the underlying layer scope
to operate correctly when running in selected features only
mode.
Fixes #17170
[processing] Allow QgsVectorLayerSelectedFeatureSource to
create expression context scopes
Allows algorithms which require the underlying layer scope
to operate correctly when running in selected features only
mode.
Fixes #17170
(cherry-picked from d5617b8)
History
#1 Updated by Andreas Neumann about 7 years ago
Update: same behaviour in QGIS 2.18. It also fails during edition in a model, but works only when executed as a single algorithm.
#2 Updated by Andreas Neumann about 7 years ago
- Assignee deleted (
Victor Olaya)
#3 Updated by Giovanni Manghi about 7 years ago
- Affected QGIS version changed from master to 2.18.13
- Category changed from Processing/QGIS to Processing/Modeller
#4 Updated by Nyall Dawson about 7 years ago
This is quite tricky to fix, because inside the model designer algorithms which are part of the model do not have knowledge of the available fields which will be present in their inputs. i.e. all it usually knows is that the input will be some vector layer, not which one or what fields it will have.
There's certain circumstances when we could determine in the designer what fields are available, e.g. when a layer source is hardcoded into a model. We could also potentially see if any previous algorithm steps in the models have added fields which we can then be certain will exist at the later 'refactor fields' stage, and show just these guaranteed fields. But that's not straightforward to do!
I've tested here (on master) and Refactor Fields works ok for me if I enter an expression using hard coded field names. They just aren't shown in the expression widget, but the expression can still include these and the model works correctly.
#6 Updated by Andreas Neumann almost 7 years ago
Now we have the situation that the Refactor fields algorithm works ok in the model when first edited, but when saved and reloaded, it doesn't work anymore.
There seems to be some expression context missing after loading of a model.
#7 Updated by Nyall Dawson over 6 years ago
- % Done changed from 0 to 100
- Status changed from Open to Closed
Applied in changeset qgis|d5617b8025e0b1ea09a4f83ca464b7306cad535b.