Skip to content

Database defined UNIQUE constraint causes conflicts #2933

@leorudczenko

Description

@leorudczenko

We believe we have found a bug involving MerginMaps mobile Input.

Summary

Our database/GeoPackage structure requires the use of the UNIQUE constraint on certain fields, specifically for primary/foreign keys. Adding a record to a table in Mergin Maps mobile Input that has a UNIQUE constraint on a field will cause a subsequent sync to fail with a conflict if the data on the server have been changed by QGIS in the meantime.

To Reproduce

We found that this can be replicated in a minimal way using the following steps:

  • Create a new project in QGIS using the MerginMaps plugin option New basic QGIS project
  • Modify the Survey_points.gpkg by adding a UNIQUE constraint to any field
  • Sync the project in QGIS
  • Download the project in MerginMaps Input - (At this point, QGIS and MerginMaps Input will have the same project in the same version)
  • Add a new point to the Survey layer in QGIS
  • Sync the new QGIS point
  • Add a new point to the Survey layer in MerginMaps Input
  • Sync the new MerginMaps Input point
  • At this point, the conflict will have occurred within MerginMaps Input, you can sync the QGIS project to verify the conflict GeoPackage file

Example Project

We have created a public MerginMaps project with these same steps applied. In this instance, the UNIQUE constraint has been applied to the photo field in the Survey_points table. You can view the project here.

It is worth noting that this issue only occurs when syncing QGIS first, and then syncing MerginMaps Input. If you sync MerginMaps Input first, and then you sync QGIS, the conflict issue does not occur. We have also tried to replicate it between 2 QGIS instances, and 2 MerginMaps Input instances, but neither of those scenarios encountered the conflict issue either.

Software Versions

We have successfully replicated this issue on multiple devices that are using the most up-to-date versions of MerginMaps Input and the MerginMaps QGIS plugin.

  • QGIS 3.32.3 for Windows
  • Mergin Maps QGIS Plugin 2023.4.1
  • Mergin Maps mobile Input 2.4.1 for Android

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions