Bug report #21788

Copy/Paste fails from one layer to another when layer has NOT NULL constraints and transaction groups are enabled

Added by Andreas Neumann almost 5 years ago. Updated almost 5 years ago.

Status:Open
Priority:High
Assignee:-
Category:Data Provider/PostGIS
Affected QGIS version:3.7(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 #:29603

Description

In a QGIS project with the following properties:
- Automatically create transaction groups where possible is enabled
- Evaluate default values on provider side is enabled
- the layer, where features will be copy/pasted in should have some NOT NULL constraints

Steps to reproduce:
- copy and paste a compatible geometry type from another layer to a Postgis layer in the transaction group

--> you will receive an error message similar to the following:

2019-04-08T11:24:45     CRITICAL    Layer naturobjekt_flaeche : PostGIS error while adding features: ERROR: null value in column "referenz_nr" violates not-null constraint
DETAIL: Failing row contains (116, e16359db-c8a5-4125-90c7-1459a3ae3fda, null, null, null, null, null, null, null, null, null, null, null, null, null, 010600002008080000010000000103000000010000001C000000713D0AD76E79...)

The new feature is not pasted because of the NOT NULL constraint and the user has no chance to add the new attribute data. The new feature is rejected right away.

Here is the CREATE TABLE statement of the concerned table:

CREATE TABLE naturobjekte_kt.naturobjekt_flaeche
(
    t_id bigint NOT NULL DEFAULT nextval('naturobjekte_kt.t_ili2db_seq'::regclass),
    t_ili_tid uuid DEFAULT uuid_generate_v4(),
    referenz_nr character varying(20) COLLATE pg_catalog."default" NOT NULL,
    objekt_nr character varying(20) COLLATE pg_catalog."default" NOT NULL,
    objekt_beschreibung character varying(255) COLLATE pg_catalog."default" NOT NULL,
    zustaendigkeit character varying(255) COLLATE pg_catalog."default" NOT NULL,
    bedeutung character varying(255) COLLATE pg_catalog."default" NOT NULL,
    verbindlichkeit character varying(255) COLLATE pg_catalog."default" NOT NULL,
    festsetzungsdatum date NOT NULL,
    ortsbezeichnung character varying(255) COLLATE pg_catalog."default",
    erfassungsgrundlage character varying(255) COLLATE pg_catalog."default",
    erfassungsdatum date NOT NULL,
    dokument character varying(255) COLLATE pg_catalog."default",
    ursprung_objekt character varying(255) COLLATE pg_catalog."default",
    bemerkungen text COLLATE pg_catalog."default",
    geometrie geometry(MultiPolygon,2056),
    CONSTRAINT naturobjekt_flaeche_pkey PRIMARY KEY (t_id)
)
WITH (
    OIDS = FALSE
)
TABLESPACE pg_default;

History

#1 Updated by Andreas Neumann almost 5 years ago

  • Subject changed from Copy/Paste fails from one layer to another when layer has constraints and transaction groups are enabled to Copy/Paste fails from one layer to another when layer has NOT NULL constraints and transaction groups are enabled

#2 Updated by Andreas Neumann almost 5 years ago

Expected behaviour would be:

- the attribute form would open
- In the form the user would see which values would have to be filled in
- after filling in required fields, the user could click OK and the feature is accepted

Also available in: Atom PDF