Commit c5f6b053 authored by Dorchies David's avatar Dorchies David
Browse files

fix(get_hydrometrie_sites): potential issue if using the "fields" parameter

Refs #7
parent ae5eae01
No related merge requests found
Showing with 16 additions and 14 deletions
+16 -14
...@@ -37,22 +37,24 @@ get_hydrometrie_sites <- function(params, ...@@ -37,22 +37,24 @@ get_hydrometrie_sites <- function(params,
) )
bFirst <- TRUE bFirst <- TRUE
for (field in fields) { for (field in fields) {
fieldValue <- unique(unlist(x[[field]])) if (!is.null(x[[field]])) {
if (unique_site && length(fieldValue) > 1) { fieldValue <- unique(unlist(x[[field]]))
if(bFirst) { if (unique_site && length(fieldValue) > 1) {
warning( if(bFirst) {
"The site '", warning(
x$code_site, "The site '",
"' has ", x$code_site,
length(fieldValue), "' has ",
" different locations, only the first one is returned", length(fieldValue),
call. = FALSE " different locations, only the first one is returned",
) call. = FALSE
bFirst <- FALSE )
bFirst <- FALSE
}
fieldValue <- x[[field]][[1]]
} }
fieldValue <- x[[field]][[1]] x[[field]] <- fieldValue
} }
x[[field]] <- fieldValue
} }
x$geometry <- NULL x$geometry <- NULL
x x
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment