Bug report #8342

WFS-T and postgis: "ERROR: null value in column "gid" violates not-null constraint" when adding features

Added by Giovanni Manghi almost 11 years ago. Updated over 10 years ago.

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

Description

When adding a feature on a WFS-T (Postgis) layer on master, the operation fails with:

@Could not commit changes to layer aapg

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

Provider errors:
unsuccessful service response: ERROR: 1 feature(s) not added.
Provider errors:
PostGIS error while adding features: ERROR: null value in column "gid" violates not-null constraint@

because the user does not fill the primary key field. This operation should be left to the software and afaik it was working as expected in older qgis releases.

Not sure is a server or client error.

History

#1 Updated by Salvatore Larosa over 10 years ago

Hi Giovanni, I think this also happens with PostGIS provider, by loading a PostGIS layer from "Add PostGIS layer"??

I can see the issue either for master or 1.8. It would be nice QGIS makes it automatically, but better if this kind of things is handled directly in PostGIS.

So if you get it working in older QGIS versions (< 1.8) this is a big blocker otherwise we can consider it as a known issue or perhaps a new feature.

What you think about it ?

#2 Updated by Giovanni Manghi over 10 years ago

Salvatore Larosa wrote:

Hi Giovanni, I think this also happens with PostGIS provider, by loading a PostGIS layer from "Add PostGIS layer"??

I would be very surprised if this is true. In fact I don't think that this is true. Were the layers you are testing moved between schemas with DB Manager? there is a bug that makes a copy of a layer (done with d&d in db manager) loose the autoincremental option in the primary key field.

I can see the issue either for master or 1.8. It would be nice QGIS makes it automatically, but better if this kind of things is handled directly in PostGIS.

So if you get it working in older QGIS versions (< 1.8) this is a big blocker otherwise we can consider it as a known issue or perhaps a new feature.

What you think about it ?

I'm pretty sure that in QGIS 1.8 the wfs-t client added automatically a proper primary key value... but it will be better to double check...

#3 Updated by Salvatore Larosa over 10 years ago

Giovanni I thought you have a primary key non sequential only with NOT NULL, isn't ?

In my case I have a PK with NOT NULL that is not working (as expected) and a PK with NOT NULL and DEFAULT value set to nexval() which seems working fine in either way (PostGIS and WFS).

So I guess your table "aapg" has a PK only with NOT NULL value.

#4 Updated by Giovanni Manghi over 10 years ago

  • Resolution set to invalid
  • Status changed from Open to Closed

Also available in: Atom PDF