Bug report #5642
return a more meaningful error when column name is duplicated
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||fixed|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||15205|
The attached shapefile does not gives any particular problem (except encondig) when loading it into postgis using ogr2ogr, shp2pgsql, spit and postgis manager, but with db manager it always fails with
Feature write errors:
Creation error for features from #0 to #199. Provider errors was:
PostGIS error while adding features: ERROR: duplicate key value violates unique constraint "alt4_pkey"
Only 1 of 201 features [email protected]
#2 Updated by Giovanni Manghi over 10 years ago
- Subject changed from shapefiles doesn't load using db manager (but works with spit, postgis manager and cli) to return a more meaningful error when column name is duplicated
it works if I check the "primary key" checkbox and change it to something else then "id", that in fact is a column name already there in the original shapefile.
Why db manager chooses to give by default the postgis id as "id" and not "gid" as usual?
Same thing for the geometry column, why "geom" instead "the_geom"?
#4 Updated by Giovanni Manghi almost 10 years ago
Giuseppe Sucameli wrote:
I cannot change the error message: that's the string retured by the DBMS and then the provider.
What I can do is to change the default pk and geometry fields' name.
gid is (was) a good choice, but why not adding a check before importing the vector, and if the case throw and error like "the column XXX already exist".