AtlasOfLivingAustralia / galah-R

Query living atlases from R
https://galah.ala.org.au
40 stars 2 forks source link

checks for `galah_filter()` don't handle multiple values that contain bracket #237

Open cjwaite23 opened 5 months ago

cjwaite23 commented 5 months ago

Describe the bug This is an error with the galah checks in galah_filter() when providing a vector of values to any field. When one of the multiple values in the vector contains brackets, the galah checks flag an issue with fields not existing which appears to ignore the content within brackets and then thinks that the entire query string is a field. Importantly this issue only occurs when multiple values are provided.

galah version galah 2.0.2

To Reproduce

### Turn checks off
galah_config(run_checks = FALSE)
# This works
galah_call() |>
  galah_filter(scientificName == c("Aviceda (Aviceda) subcristata", "Todiramphus (Todiramphus) sanctus")) |>
  atlas_counts()
#> # A tibble: 1 × 1
#>    count
#>    <int>
#> 1 326093

### Turn checks on
galah_config(run_checks = TRUE)
# And the same code doesn't with checks on
galah_call() |>
  galah_filter(scientificName == c("Aviceda (Aviceda) subcristata", "Todiramphus (Todiramphus) sanctus")) |>
  atlas_counts()
#> Error in `check_fields()`:
#> ! Can't use fields that don't exist.
#> ℹ Use `search_all(fields)` to find a valid field ID.
#> ✖ Can't find field(s) in
#>   • `galah_filter()`: Aviceda subcristata" OR scientificName
# but it does work without brackets:
galah_call() |>
  galah_filter(species == c("Aviceda subcristata", "Todiramphus sanctus")) |>
  atlas_counts()
#> # A tibble: 1 × 1
#>    count
#>    <int>
#> 1 328595
# or with just one name with brackets
galah_call() |>
  galah_filter(scientificName == c("Aviceda (Aviceda) subcristata")) |>
  atlas_counts()
#> # A tibble: 1 × 1
#>   count
#>   <int>
#> 1 31889

Expected behaviour We would expect the bug to behave as shown above when checks are off - the check issueshould not be flagged