AtlasOfLivingAustralia / galah-R

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

`galah_filter` (sometimes) fails to parse OR statements correctly #154

Closed mjwestgate closed 9 months ago

mjwestgate commented 1 year ago

The documentation for galah_filter includes the following example, which parses correctly:

galah_filter(year == 2020 | year == 2021)
# A tibble: 1 × 4
  variable logical value                           query                             
  <chr>    <chr>   <chr>                           <chr>                             
1 year     ==      "c(\\\"2020\\\", \\\"2021\\\")" "(year:\"2020\" OR year:\"2021\")"

However, this example fails:

galah_filter(raw_scientificName == "Litoria jervisiensis" | raw_scientificName == "Litoria peronii")
# A tibble: 1 × 4
  variable           logical value                query                                          
  <chr>              <chr>   <chr>                <chr>                                          
1 raw_scientificName ==      Litoria jervisiensis "(raw_scientificName:\"Litoria jervisiensis\")"

Probably a simple fix, but will need some careful checking. And a new test.

NenBarto commented 1 year ago

I've noticed something similar. The code below fails if there are three conditions, but works ok if there are only two (any of the three). Any suggestions? Thaaanks! :) galah_call() %>% galah_identify("Vertebrata") %>% galah_filter(basisOfRecord == "HumanObservation" | basisOfRecord == "MachineObservation" | basisOfRecord == "Observation") %>% galah_group_by(year, basisOfRecord) %>% atlas_counts()