Bug report #20207
GeoPackage column misalignment after spatial join due to fid attribute
Status: | Closed | ||
---|---|---|---|
Priority: | High | ||
Assignee: | Luigi Pirelli | ||
Category: | Processing/Core | ||
Affected QGIS version: | 3.2.3 | Regression?: | No |
Operating System: | Easy fix?: | No | |
Pull Request or Patch supplied: | No | Resolution: | wontfix |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 28028 |
Description
Issue might be related to: #19708
Having a polygon layer in gpkg format and a point layer in *.shp format if you
- join attributes by location (polygon attribute joined to points)
- join all columns (that includes the fid column)
- save result to gpkg
Due to the fact that the result would contain 2 columns named "fid" one of them (the joined one) gets removed and the attributes misalign.
At the moment the only ways to prevent this are:
- select columns to join and exclude the fid column
- prefix the joined columns
If a user is not aware of this, this leads to data loss.
If the above mentioned workarounds are not used, QGIS should automatically rename the joined "fid" column to "fid_2" or something along those lines.
History
#1 Updated by Giovanni Manghi about 6 years ago
- Status changed from Open to Feedback
do the original layers get changed in the process? if no then there is no data loss (not that a wrong result is better).
#2 Updated by Andreas Wicht about 6 years ago
Giovanni Manghi wrote:
do the original layers get changed in the process? if no then there is no data loss (not that a wrong result is better).
no, the original ones not, the loss is in the result. Sorry for misinterpreting the field. You can change it back to "no" then.
#3 Updated by Giovanni Manghi about 6 years ago
- Crashes QGIS or corrupts data changed from Yes to No
- Operating System deleted (
Windows 10 / Ubuntu 18.04) - Status changed from Feedback to Open
#4 Updated by Jürgen Fischer about 6 years ago
- Description updated (diff)
#6 Updated by Luigi Pirelli almost 6 years ago
the user is notified because choosing fid as PK (1,1,2,2,2) generate PK violation and record [1,3,4] are not added during save generating an error message as attached image (sorry it's in spanish because I was testing encoding errors)
#7 Updated by Luigi Pirelli almost 6 years ago
- Resolution set to wontfix
After verification with Giovanni Manghi we decided to close because the error message sent to the user is enough to understand the wrong use to "Save Vector Feature as" default parameters.
If the user leave fid as PK and the PK does not have unique values, the error is raised. It's responsibility to the user to understand the generated data and do not use PK that does not have unique values.
#8 Updated by Luigi Pirelli almost 6 years ago
- Status changed from Open to Closed