getodk / collect

ODK Collect is an Android app for filling out forms. It's been used to collect billions of data points in challenging environments around the world. Contribute and make the world a better place! ✨📋✨
https://docs.getodk.org/collect-intro
Other
719 stars 1.38k forks source link

`pulldata` should support local entities #6443

Closed seadowg closed 1 month ago

seadowg commented 1 month ago

Currently, using pulldata with an entity list will not work as expected as the data queried will be the entity list CSV rather than the local entities so data entities may not exist or may be out of date. pulldata should work correctly in these cases and use the local entities.

For the moment, search does not need to support local entities.

Notes

pulldata is implemented as a custom function (ExternalDataHandlerPull). As we're most likely going to be removing the current implementation (and just treat pulldata as sugar for optimised queries) we should create a new custom function that wraps the current implementation and just expands pulldata to a "normal" filter expression if the filtered instance is an entity list. For example, pulldata('fruits', 'name', 'name_key', 'mango') should just be treated as instance('fruits')/root/item[name_key='mango'][1]/name.

seadowg commented 1 month ago

@lognaturel is my mapping of pulldata to a normal filter correct here?

lognaturel commented 1 month ago

The last name_key should be name but otherwise that's right. Good call on the [1], that's an important one.

lognaturel commented 1 month ago

Some review comments to address at https://github.com/getodk/collect/pull/6451#pullrequestreview-2375809634