Bug report #20207
GeoPackage column misalignment after spatial join due to fid attribute
|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|
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.
#2 Updated by Andreas Wicht almost 2 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.
#6 Updated by Luigi Pirelli over 1 year 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 over 1 year 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.