mobile icon indicating copy to clipboard operation
mobile copied to clipboard

Warn if user has 1-N relation and FID

Open saberraz opened this issue 4 years ago • 5 comments

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.

saberraz avatar Sep 17 '21 08:09 saberraz

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:

  • step 1: add warnings to the Mergin QGIS plugin and links to the docs
  • step 2: implement support for foreign keys in geodiff + add functionality to Mergin QGIS plugin (or even directly to QGIS) to add foreign keys where relations are used

wonder-sk avatar Sep 17 '21 09:09 wonder-sk

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...

PeterPetrik avatar Sep 17 '21 09:09 PeterPetrik

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: image

QGIS works correctly:

image

Input doesn't work: InkedScreenshot_20210929-152913_LI

I do not understand if it is related to this bug.

rmarzocchi84 avatar Sep 29 '21 13:09 rmarzocchi84

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.

mdouchin avatar Dec 02 '21 18:12 mdouchin

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?

PeterPetrik avatar Oct 16 '23 11:10 PeterPetrik

QGIS mergin plugin has already validator for this case (MerginMaps/qgis-plugin#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?

I'd say we close the issue, fixed in the plugin :)

tomasMizera avatar Dec 12 '25 20:12 tomasMizera