Bug report #21036

QGIS3, pasting a .shp source with 'gid' field presented into a postgis layer now doesn't ignore the source 'gid' like it seems do in 2.18

Added by sand thorn over 1 year ago. Updated over 1 year ago.

Status:Open
Priority:Normal
Assignee:-
Category:Editing
Affected QGIS version:3.4.3 Regression?:Yes
Operating System:Windows 10 64-bit Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:28855

Description

When pasting from .shp source with 'gid' into a postgis layer, in 2.18 it just ignore the 'gid' of the source.
As a result, you got complained when trying to save editing

Could not commit changes to layer <layername>

Errors: ERROR: 6849 feature(s) not added.

Provider errors:
PostGIS error while adding features: ERROR: duplicate key value violates unique constraint "&lt;layername&gt;_pkey"
DETAIL: Key (gid)=(2) already exists.

WORKAROUND: manually delete .shp source's gid field before copying

History

#1 Updated by Frédéric CLOITRE over 1 year ago

Hi

I'm having the same kind of problem.

While copying an object from a different source (shapefile or geopackage) with a different attribute table, I encounter constraint-related errors on my destination table (in next example, the id field is of type "SERIAL PRIMARY KEY" in PostGreSQL, so, PostgreSQL generates id).
In QGIS2, we could modify the attribute data of the object before recording in the database, I have the feeling that QGIS3 directly records the object in database juste after paste.

Couche Zone d'étude: Erreur PostGIS lors de l'ajout d'entité : ERROR: null value in column "id" violates not-null constraint DÉTAIL : Failing row contains (null, null, null, null, null, 01060000206A0800000100000001030000000100000008000000E168F3A9AC44..., lpo07, 26147.2168980213, 2019-01-21 16:49:14.036585+01, null). 

Also available in: Atom PDF