From c4e2d01051f7eb215e08ba62542f57a7545048a8 Mon Sep 17 00:00:00 2001 From: your name Date: Thu, 18 Jul 2024 23:10:29 -0400 Subject: [PATCH 1/2] Fix error when `page_size = NULL` Consolidate page_size input check in validate_page_size and remove redundant checks --- R/arc-select.R | 55 ++++++++++++++++---------------------------------- 1 file changed, 17 insertions(+), 38 deletions(-) diff --git a/R/arc-select.R b/R/arc-select.R index 7d726f8..d9e31e8 100644 --- a/R/arc-select.R +++ b/R/arc-select.R @@ -86,17 +86,6 @@ arc_select <- function( check_string(where, allow_null = TRUE, allow_empty = FALSE) check_character(fields, allow_null = TRUE) - - check_number_whole(as.integer(page_size), min = 1, allow_null = TRUE) - check_number_whole( - as.integer(page_size), - # bug in the standalone checks - # needs to be a double and cannot be used with - # max at the same time which is why it is brought into two calls - max = as.double(x[["maxRecordCount"]]), - allow_null = TRUE - ) - # extract the query object query <- attr(x, "query") @@ -216,7 +205,7 @@ collect_layer <- function( # get existing parameters # determine_format() chooses between pbf and json - out_f <- determine_format(x) + out_f <- determine_format(x, call = error_call) query_params <- validate_params( query, @@ -600,35 +589,24 @@ validate_page_size <- function( page_size = NULL, max_records = NULL, error_call = rlang::caller_env()) { - # if page_size is null, use max records (default) - page_size <- page_size %||% max_records - - # coerce to integer - page_size <- as.integer(page_size) - - if (!is.numeric(page_size) && !length(page_size) == 0) { - cli::cli_abort( - "{.arg page_size} must be a numeric scalar, - not {.obj_type_friendly {page_size}}", - call = error_call - ) + if (is.numeric(page_size)) { + # coerce to integer if page_size is numeric + page_size <- as.integer(page_size) } - page_size_len <- length(page_size) - - if (!rlang::has_length(page_size, 1)) { - cli::cli_abort( - "{.arg page_size} must be length 1, not {page_size_len}", - call = error_call - ) - } + check_number_whole(page_size, min = 1, allow_null = TRUE, call = error_call) + check_number_whole( + page_size, + # bug in the standalone checks + # needs to be a double and cannot be used with + # max at the same time which is why it is brought into two calls + max = as.double(max_records), + allow_null = TRUE, + call = error_call + ) - if (page_size < 1) { - cli::cli_abort( - "{.arg page_size} must be a positive integer.", - call = error_call - ) - } + # if page_size is null, use max records (default) + page_size <- page_size %||% max_records if (is.numeric(max_records) && (page_size > max_records)) { cli::cli_abort( @@ -646,6 +624,7 @@ validate_page_size <- function( supports_pbf <- function(x, arg = rlang::caller_arg(x), call = rlang::caller_call()) { # verify that x is an layer + # FIXME: This check makes arc_select error on ImageServer inputs obj_check_layer(x, arg, call) # extract supported query formats From f33972695afc8ff60887ddd8d3933b773f4a0a2a Mon Sep 17 00:00:00 2001 From: Josiah Parry Date: Tue, 23 Jul 2024 21:15:17 -0400 Subject: [PATCH 2/2] Update R/arc-select.R --- R/arc-select.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/R/arc-select.R b/R/arc-select.R index d9e31e8..901fb57 100644 --- a/R/arc-select.R +++ b/R/arc-select.R @@ -625,7 +625,12 @@ validate_page_size <- function( supports_pbf <- function(x, arg = rlang::caller_arg(x), call = rlang::caller_call()) { # verify that x is an layer # FIXME: This check makes arc_select error on ImageServer inputs - obj_check_layer(x, arg, call) + check_inherits_any( + x, + class = c("FeatureLayer", "Table", "ImageServer"), + arg = arg, + call = call + ) # extract supported query formats query_formats_raw <- x[["supportedQueryFormats"]]