Bug report #20207

GeoPackage column misalignment after spatial join due to fid attribute

Added by Andreas Wicht over 5 years ago. Updated about 5 years ago.

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.

join_bug_pt.zip - Points (1.17 KB) Andreas Wicht, 2018-10-24 01:21 PM

join_bug.gpkg - GeoPackage (172 KB) Andreas Wicht, 2018-10-24 01:21 PM

Captura de pantalla de 2019-02-12 14-55-58.png (46.3 KB) Luigi Pirelli, 2019-02-12 02:55 PM

History

#1 Updated by Giovanni Manghi over 5 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 over 5 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 over 5 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 over 5 years ago

  • Description updated (diff)

#5 Updated by Luigi Pirelli about 5 years ago

  • Assignee set to Luigi Pirelli

investigating

#6 Updated by Luigi Pirelli about 5 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 about 5 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 about 5 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF