MerginMaps / mobile

Mobile app for Mergin Maps 📲. Open QGIS projects and manage vector data on your phone, even offline 📶 (Android/iOS/Windows app)
https://merginmaps.com
GNU General Public License v2.0
294 stars 64 forks source link

Filter expression not working for Value Relation widget in 2024.1.0 #3429

Closed raherin closed 4 months ago

raherin commented 4 months ago

When using a filter expression on a value relations widget, the app will add all values that meet the filter expression when only one value is selected in the drop-down menu while filling out the form. This can be reproduced in the example project support/form_setup.

To reproduce the issue:

  1. Have a survey layer with a Value Relation widget and set a filter expression based on the value of another field:

    image
  2. The expected behaviour, which is reproduced in QGIS, is that when selecting a plant type in the form, you will be able to select a plant of that type in the form. In this case, 'Vegetable' was selected as the plant type and 'Carrot' as the plant species:

    image
  3. When filling out the form in the app, all of the species are saved to the field in the form. See video below:

https://github.com/MerginMaps/mobile/assets/26321345/1acb0518-53bc-4233-900d-e86ee86c6773

uclaros commented 4 months ago

This weird behavior is actually caused by the project not being set up properly:

While the value relation for field type is properly set:

The value relation for sub-type is wrong:

Setting the Key column to either fid or Species solves it, as there is now a 1-1 connection to the Value values.

So the question is: what should be displayed when the selected Key corresponds to multiple Values, and should we somehow warn users about it? QGIS handles it by displaying the first matching value. I believe our approach is more correct, we display a concatenated string of all corresponding values.

wonder-sk commented 4 months ago

Note: there is a ticket for the plugin to detect such problems: https://github.com/MerginMaps/qgis-plugin/issues/317

tomasMizera commented 4 months ago

Ping @raherin