Bug report #18241
QgsVectorJoinInfo.setJoinFieldNamesSubset() wrong fields order
Status: | Open | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | Vectors | ||
Affected QGIS version: | 3.1(master) | Regression?: | No |
Operating System: | Archlinux, Ubuntu | Easy fix?: | No |
Pull Request or Patch supplied: | No | Resolution: | |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 26132 |
Description
By creating a join, via Python, if a subset of fields to be joined is defined, the joined fields will be in the same order as in the joined layer, but the values will be in the order of the list passed to setJoinFieldNamesSubset instead.
For example, by joining the 2 following layers
with this code
join = QgsVectorLayerJoinInfo()
join.setJoinLayer(layer_1)
join.setJoinFieldName('id')
join.setTargetFieldName('id')
join.setJoinFieldNamesSubset(['column_b', 'column_a'])
layer_2.addJoin(join)
I get the following result
where the data of the 2 fields are in different order compared to the name of the fields
I tested it on 2.18.11 on Archlinux and master on Ubuntu with the same result. Attached, the complete python code to test this example on QGIS 2.18 and QGIS 3.0