[QGIS-Developer] issues with relations and embedded forms
Matthias Kuhn
matthias at opengis.ch
Tue Feb 25 09:05:02 PST 2020
Hi Alessandro,
On 2/25/20 5:49 PM, Alessandro Pasotti wrote:
> Hi,
>
> it's probably me not being a power user, but from a few simple tests
> I'm doing with relations (1:n) on spatialite/gpkg layers I'm
> experiencing a few issues and I wonder if there is something I missed
> or if we can improve the workflow.
>
> My test schema is pretty simple:
> -----------
> table1 (parent)
> -----------
> fid (default: sqlite_fetch_and_increment...)
> name
>
> -----------
> table2 (child)
> -----------
> fid
> fk_table1 -> table1.fid
> name
>
> ISSUE 1:
> - add a new item in table1
> - in the embedded form add a table2 item
> - click on "Save child layer edits" button -> backend CONSTRAINT
> FAILURE! because table1 parent is not saved (and not even in the
> editing buffer, for what matters)
>
> QUESTIONS on ISSUE1:
> - should we disable the "Save child layer edits" button in case the
> parent is unsaved?
> - what's the idea behind the "Save child layer edits" when the user
> cannot even save the parent from the form, why can she save the children?
> - would it make sense to check for the unsaved parent in
> QgsRelationEditorWidget::saveEdits() before attempting a children save?
It works under some given pre-conditions:
- Working with non database systems (shp, xls, ..., risk of data
inconsistencies)
- Working with database systems without fk constraints (risk of data
inconsistencies)
- Working with databases with transaction mode enabled and deferred fk
checks (<-- it was designed for this exact use case)
I'm not sure how to best improve the situation here and help users to
prepare their system apart from documentation. Ideas welcome.
>
> ISSUE 2:
> - preparation: add one parent and a few children and commit
> - activate identify tool and click on a parent feature
> - the form opens but no children are shown in the child form, all
> values are NULL, I would expect that the first child is automatically
> selected and focused
Agreed, annoying!
>
> ISSUE 3:
> - preparation: add one parent and a few children and commit
> - activate identify tool and click on a parent feature
> - click on "Add Point child feature"
> - click on map canvas
> - another attribute form opens, I would expect that instead of opening
> a new form, the embedded form was focused, with the new feature
> geometry associated and ready for input of other field values, the
> form open may be fixed with the option I've added here:
> https://github.com/qgis/QGIS/pull/34654.
That's likely a tricky thing to accomplish with transaction mode enabled
because to bring it into the embedded form it has first to be sent to
the DB and NOT NULL (and other) constraints satisfied which is hard to
guarantee before opening a form.
>
> Before I attempt any further patches, I'd like to hear your opinion on
> how we could make the data entry process a little bit easier and
> error-proof in case of parent-child relations, especially now that
> QGIS is dropping the GIS and becoming the new Access ;)
I think the easiest solution would be to just drop all foreign keys and
other constraints on production databases, they just tend to mess up
things ;P
Matthias
>
> Cheers
>
>
> --
> Alessandro Pasotti
> w3: www.itopen.it <http://www.itopen.it>
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20200225/094b23d8/attachment-0001.html>
More information about the QGIS-Developer
mailing list