Bug report #8245

SpatiaLite export fails if ogc_fid is present in source table

Added by Andreas Neumann over 11 years ago. Updated over 11 years ago.

Status:Closed
Priority:High
Assignee:-
Category:Vectors
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:17056

Description

When exporting from a Postgis table and if the source table contains a column named "ogc_fid" one cannot export the table to SpatiaLite.

The following error message is issued:

Export in Vektordatei schlug fehl.
Fehler: Erzeugung des Felds ogc_fid gescheitert (OGR-Fehler: Failed to add field ogc_fid to table strassenachse:
 duplicate column name: ogc_fid)

Seems like the SpatiaLite exporter always creates a column named "ogc_fid" and then it tries to create the same column name again. It would be good if the exporter could detect and handle this situation by just transfering the Postgis primary key to the SpatiaLite primary key.

Associated revisions

Revision ac21c626
Added by Jürgen Fischer over 11 years ago

save as: add a numeric postfix to reserved field ogc_fid when saving to SQLite (fixes #8245)

History

#1 Updated by Andreas Neumann over 11 years ago

I mean export with "Save as" (right-click on layer in legend tree).

#2 Updated by Jürgen Fischer over 11 years ago

  • Category changed from Data Provider/SpatiaLite to Vectors

#3 Updated by Jürgen Fischer over 11 years ago

  • Status changed from Open to Closed

#4 Updated by Jürgen Fischer over 11 years ago

Jürgen Fischer wrote:

Fixed in changeset ac21c62662164156d7e1905303ab9456b208bdd9.

"Save As" is based on OGR and OGR uses ogc_fid as internal key which is automatically created (unlike the spatialite provider it even mask it's existance, when loading layers via OGR). The fix now renames the source field to ogc_fid0 (or up to ogc_fid9, if that produces a clash).

Also available in: Atom PDF