Open saberraz opened 2 years ago
This is something that should be handled in the Mergin QGIS plugin. Geodiff has no way of knowing about relations, and even if it knew because of foreign keys, these are not supported yet https://github.com/lutraconsulting/geodiff/issues/39
If we want to have Input to correctly handle this situation, we should:
They can use relations if they do NOT use the feature FID as reference key. Best it to have extra UUID auto-generated column in the parent table, so the geodiff rebasing does not mess up with those...
In my case the Parent reference defined in QGIS is lost on the Input app and I cannot add record whih are referenced to parent layer.
Here my definition on QGIS:
QGIS works correctly:
Input doesn't work:
I do not understand if it is related to this bug.
I would also encourage a lot to use UUIDS columns as references, and never user FID (ou PostgreSQL id serials). In most cases, the performance impact will be negligeable, and this will ease a lot the workflow. I always use UID columns in the relations definition.
FIDs and PostgreSQL serials will still be used to have integer features ids (better for performances).
By the way, thanks a lot for releasing and maintaining geodiff.
QGIS mergin plugin has already validator for this case (https://github.com/MerginMaps/qgis-mergin-plugin/pull/380) and in the mobile app we can possibly add a warning to the project warning dialog (similarly to invalid CRS or missing layers), but nothing more. Do we want to do it or shall we just close this issue?
In most cases, users will use the FID of a GeoPackage as the field for their Parent layer in the 1-N relation. The problem comes when you sync the project: the FID gets overwritten by Geodiff which subsequently breaks the relation between the correct FID and the Child layer.
We need to detect if FID is used for a relation, and if so, update the relation to use the new FID assigned to the layer.