Bug report #7271
column indexing issue with joined tables
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||all||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||fixed|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||16287|
I've spotted a pretty serious bug with joined columns in the attributes table window and symbology classification. Basically, all of the columns following the column which is used to join two tables will be wrongly indexed by not taking into account the removed column which was joined.
id | name | date
To be joined by this XLS Table:
shared_id | extra_a | extra_b | extra_c
When joined, the resulting table would be:
id | name | date | extra_a | extra_b | extra_c
The shared_id column is merged with id, and therefore doesn't show. What seems to happen however is that the QGIS' table column index still takes into account shared_id. So when the user open the attribute table window and try to sort extra_a by clicking on its header, it'll end up sorting extra_b as the extra_a header refers to an index which takes into account shared_id.
Similarly, when doing symbology's graduated / categorized classification by selecting a joined column, the same shift happens.
#1 Updated by Mathieu Pellerin - nIRV over 8 years ago
#3 Updated by Mathieu Pellerin - nIRV over 8 years ago
Practical example with steps to reproduce issue:
1. Open villages_point.shp (projection is indian 1960 48n, but it's irrelevant to this issue)
2. Open v4_CAM_HeadCount_MotherTongue_Multilevel_Census2008.xls, and select the "By Village" layer
3. Open the village_point property window and enter the joins tab
4. Click on the [+] button to add a join as such: join layer "By Village", join field "Code_Phum_STRING", target field "VILL_CODE"
5. Apply the join and leave the property window by clicking on ok.
6. Open village_point's attribute table, and go to the end of the columns to view the joined columns, make sure row 0 is at the top.
7. Click on the "By Village_Por" column header twice (to sort by highest to lowest number)
At that stage, you should clearly see the sorting occurs not the header your clicking but the one to its right, that is "By Village_Suoy" in this specific case.