Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AkiTuomaala opened this issue May 7, 2024 · 0 comments

Comments

@AkiTuomaala
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant