Skip to content

Commit 63cf157

Browse files
authored
Merge pull request #209 from elipousson/R-ArcGIS-main
Fix error with `arc_select()` when `page_size = NULL` (fix #212)
2 parents 754bd2d + f339726 commit 63cf157

File tree

1 file changed

+23
-39
lines changed

1 file changed

+23
-39
lines changed

R/arc-select.R

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,6 @@ arc_select <- function(
8686
check_string(where, allow_null = TRUE, allow_empty = FALSE)
8787
check_character(fields, allow_null = TRUE)
8888

89-
90-
check_number_whole(as.integer(page_size), min = 1, allow_null = TRUE)
91-
check_number_whole(
92-
as.integer(page_size),
93-
# bug in the standalone checks
94-
# needs to be a double and cannot be used with
95-
# max at the same time which is why it is brought into two calls
96-
max = as.double(x[["maxRecordCount"]]),
97-
allow_null = TRUE
98-
)
99-
10089
# extract the query object
10190
query <- attr(x, "query")
10291

@@ -216,7 +205,7 @@ collect_layer <- function(
216205
# get existing parameters
217206

218207
# determine_format() chooses between pbf and json
219-
out_f <- determine_format(x)
208+
out_f <- determine_format(x, call = error_call)
220209

221210
query_params <- validate_params(
222211
query,
@@ -600,35 +589,24 @@ validate_page_size <- function(
600589
page_size = NULL,
601590
max_records = NULL,
602591
error_call = rlang::caller_env()) {
603-
# if page_size is null, use max records (default)
604-
page_size <- page_size %||% max_records
605-
606-
# coerce to integer
607-
page_size <- as.integer(page_size)
608-
609-
if (!is.numeric(page_size) && !length(page_size) == 0) {
610-
cli::cli_abort(
611-
"{.arg page_size} must be a numeric scalar,
612-
not {.obj_type_friendly {page_size}}",
613-
call = error_call
614-
)
592+
if (is.numeric(page_size)) {
593+
# coerce to integer if page_size is numeric
594+
page_size <- as.integer(page_size)
615595
}
616596

617-
page_size_len <- length(page_size)
618-
619-
if (!rlang::has_length(page_size, 1)) {
620-
cli::cli_abort(
621-
"{.arg page_size} must be length 1, not {page_size_len}",
622-
call = error_call
623-
)
624-
}
597+
check_number_whole(page_size, min = 1, allow_null = TRUE, call = error_call)
598+
check_number_whole(
599+
page_size,
600+
# bug in the standalone checks
601+
# needs to be a double and cannot be used with
602+
# max at the same time which is why it is brought into two calls
603+
max = as.double(max_records),
604+
allow_null = TRUE,
605+
call = error_call
606+
)
625607

626-
if (page_size < 1) {
627-
cli::cli_abort(
628-
"{.arg page_size} must be a positive integer.",
629-
call = error_call
630-
)
631-
}
608+
# if page_size is null, use max records (default)
609+
page_size <- page_size %||% max_records
632610

633611
if (is.numeric(max_records) && (page_size > max_records)) {
634612
cli::cli_abort(
@@ -646,7 +624,13 @@ validate_page_size <- function(
646624

647625
supports_pbf <- function(x, arg = rlang::caller_arg(x), call = rlang::caller_call()) {
648626
# verify that x is an layer
649-
obj_check_layer(x, arg, call)
627+
# FIXME: This check makes arc_select error on ImageServer inputs
628+
check_inherits_any(
629+
x,
630+
class = c("FeatureLayer", "Table", "ImageServer"),
631+
arg = arg,
632+
call = call
633+
)
650634

651635
# extract supported query formats
652636
query_formats_raw <- x[["supportedQueryFormats"]]

0 commit comments

Comments
 (0)