Bug report #16636

Delete child feature in Relation Reference Widget (n:m-Relations)

Added by Manuel K almost 7 years ago. Updated over 6 years ago.

Status:Closed
Priority:Normal
Assignee:Matthias Kuhn
Category:Forms
Affected QGIS version:2.18.9 Regression?:No
Operating System:Windows 7 Pro 64 bit Easy fix?:No
Pull Request or Patch supplied:No Resolution:invalid
Crashes QGIS or corrupts data:No Copied to github as #:24536

Description

The Deletion of a child Feature doesn't work.
When selecting an existing child feature the "Delete child Feature" button becomes active and when clicking the button, the child feature disappears in the form. However the feature is not deleted in PostGIS (although not linked to another feature) an reppears again after saving data and reopening the form.

Side note:
Option "Automatically create Transaction Groups where possible" ist selected and all data sources of the layers have the same DB user.

History

#1 Updated by Matthias Kuhn almost 7 years ago

This happens when there is no "ON DELETE CASCADE" flag set on the foreign key.

With tables A <- (L)inking -> B

And a foreign key constraint L_B_fkey on L, do the following

ALTER TABLE L
DROP CONSTRAINT L_B_fkey;

ALTER TABLE L
ADD CONSTRAINT L_B_fkey FOREIGN KEY (foreign_key_field_name)
REFERENCES B (primary_key_field) MATCH SIMPLE
ON DELETE CASCADE;

#2 Updated by Giovanni Manghi over 6 years ago

  • Priority changed from High to Normal
  • Status changed from Open to Feedback

#3 Updated by Giovanni Manghi over 6 years ago

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

Closing for lack of feedback, please reopen if necessary.

Also available in: Atom PDF