diff --git a/R/get_ogc_data.R b/R/get_ogc_data.R index d78519fd..89ebb630 100644 --- a/R/get_ogc_data.R +++ b/R/get_ogc_data.R @@ -171,14 +171,9 @@ switch_properties_id <- function(properties, id) { } if (length(properties) == 0) { - # If a user requested only id and/or geometry, properties is now empty. - # The feature "id" always comes back (and geometry is handled by - # skipGeometry), so omit the properties filter entirely rather than - # requesting "id": several collections (e.g. daily, continuous) now - # reject "id" as a selectable property, and it also fails the - # available-properties check below. rejigger_cols() still subsets the - # result to the requested id column. - properties <- NA_character_ + # If a user requested only id and/or geometry, properties would now be empty + # geometry is taken care of with skipGeometry + properties <- "id" } } diff --git a/tests/testthat/tests_general.R b/tests/testthat/tests_general.R index f0830ffa..25d272e5 100644 --- a/tests/testthat/tests_general.R +++ b/tests/testthat/tests_general.R @@ -648,35 +648,3 @@ test_that("format_dates", { "2025-10-01/2026-02-02" ) }) - -test_that("switch_properties_id drops id and geometry from the wire properties", { - # The feature "id" always comes back (renamed to the service id - # downstream) and several collections (e.g. daily, continuous) now reject - # "id" as a selectable property, so it must never be sent. A request for - # only id and/or geometry must omit the properties filter (NA), not fall - # back to "id". - expect_true(all(is.na( - dataRetrieval:::switch_properties_id("daily_id", id = "daily_id") - ))) - expect_true(all(is.na( - dataRetrieval:::switch_properties_id("id", id = "daily_id") - ))) - expect_true(all(is.na( - dataRetrieval:::switch_properties_id(c("daily_id", "geometry"), id = "daily_id") - ))) - - # Mixed requests: the id alias and geometry are dropped, real properties kept. - expect_equal( - dataRetrieval:::switch_properties_id(c("daily_id", "value"), id = "daily_id"), - "value" - ) - expect_equal( - dataRetrieval:::switch_properties_id(c("id", "value", "geometry"), id = "daily_id"), - "value" - ) - - # No properties requested -> unchanged (NA passes through). - expect_true(all(is.na( - dataRetrieval:::switch_properties_id(NA, id = "daily_id") - ))) -})