Bug report #8245
SpatiaLite export fails if ogc_fid is present in source table
|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|
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.
#4 Updated by Jürgen Fischer about 8 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).