opengisch / QField

A simplified touch optimized interface for QGIS

Home Page:http://www.qfield.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Saving on postgis View with INSTEAD OF trigger gives error even when it works right

AkiTuomaala opened this issue · comments

Issue

When saving on layer what is made as VIEW on postgres, QField gives error "Couldn't save changes". When I cancel changes it still saved everything like it should on right tables inside postgres.

Reproduction steps

1 Create Table
CREATE TABLE pointdata ( uid uuid NOT NULL DEFAULT uuid_generate_v4() PRIMARY KEY, geom GEOMETRY(PointZ, 4326) );

  1. CREATE VIEW
    CREATE OR REPLACE VIEW pointview AS SELECT s.uid, geom FROM pointdata s;

  2. CREATE trigger function
    CREATE OR REPLACE FUNCTION "addPointToTable"() RETURNS trigger LANGUAGE 'plpgsql' COST 100 VOLATILE NOT LEAKPROOF AS $$ DECLARE pointuuid uuid; BEGIN IF TG_OP = 'INSERT' THEN SELECT uuid_generate_v4() INTO pointuuid ; INSERT INTO pointdata (uid, geom) VALUES (pointuuid , NEW.geom); RETURN NEW; END IF; RETURN NEW; END; $$;

  3. Add trigger to View
    CREATE TRIGGER addPointToTable INSTEAD OF INSERT ON pointview FOR EACH ROW EXECUTE FUNCTION "addPointToTable"();

Expected behavior

In QGIS when I try to save on view. There is no errors and data goes to right table (pointtable)

Observed behavior

In Qfield there raises error that data has been commited, but couldn't get feature -2.

Desktop (please complete the following information)

  • Qgis 3.28.5

Mobile

  • Device: Lenovo Tab M10
  • OS: Android 12
  • Qfield 3.2.2 - Congo