-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Using "Add feature" to create feature and child feature with transaction group causes foreign key error #37222
Comments
@jdugge does it mean that in a previous QGIS release this example worked as documented? |
I'm not sure if this exact action (creating a new feature using the "Add Record" tool and then creating a new child feature from the attribute form) ever worked. I tried this with QGIS 3.2, 3.6, 3.10 and 3.12, and current master, and the behaviour is always the same. |
Poking around the code, it seems the difference in behaviour stems from the fact that when using the "Add Record" tool a It might be more consistent and intuitive for the user if |
@jdugge is there another bug here (even if this issue was fixed)? When the user adds a new feature from the top menu (like in GIF 1) there is a "Cancel" button in the dialog, but it has no effect (due to the transaction). |
@jdugge I'd appreciate if you could test my patch, if you are on windows you'll find a built test package in a about an hour and a half (search for "Artifact"): https://github.com/qgis/QGIS/actions/runs/137201841 |
@elpaso: Excellent, that works great! |
Thanks for testing, I'm preparing a new patch with a different and possibly cleaner approach (that requires ticking the checkbox "Evaluate on provider side", the same way as postgis is supposed to work. In any event I won't be able to fix the "dirty project" issue, for GPKG at least the evaluation has the side effect that the sequence is actually incremented and due to the fact that's inside the GDAL/OGR library and I cannot get an handle to the sqlite DB so I cannot add the increment inside the transaction, that means that the sequence will be permanently incremented each time a feature is added, even if it's not saved. |
for PK default value, fixes qgis#37222 Also, fix dangling transactions for spatialite.
for PK default value, fixes #37222 Also, fix dangling transactions for spatialite.
for PK default value, fixes qgis#37222 Also, fix dangling transactions for spatialite.
The QGIS documentation includes an example of creating many-to-many relationships with PostGIS and Geopackage databases, using transaction groups and two one-to-many relations on a junction table.
After working through the example using Geopackage in QGIS 3.12 a "foreign key error" occurs when trying to simultaneously create a new feature with a new child feature using the "Add record (Ctrl + .)" menu, see the GIF below:
This might be due to the fact that the
id
field of the new feature is not automatically filled when going through "Add record" (instead it reads "Autogenerate"). When adding a new feature using the attribute table theid
is already filled in, and creating a new feature with a new child feature works without problems, see the GIF below:A QGIS project and Geopackage file for testing is attached:
many_to_many.zip
The text was updated successfully, but these errors were encountered: