Skip to content

Commit bd83f9f

Browse files
authored
Merge pull request #187 from elipousson/arc_select-field-order-fix
Fix #185
2 parents 69acc89 + ca8d110 commit bd83f9f

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Add `alias` argument to `arc_read()` allowing replacement or labelling of field names with alias values (#169)
55
- Add `pull_field_aliases()` utility function
66
- `arc_select()` now uses `arcgisutils::rbind_results()` for faster row-binding if `{collapse}`, `{data.table}`, `{vctrs}` are installed (#175)
7+
- Preserve order of `fields` column names for `arc_select()` (fixes minor bug with `arc_read` handling of `col_names`) (#185)
78

89
# arcgislayers 0.2.0
910

R/arc-select.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ collect_layer <- function(
248248
# selected
249249
if (rlang::is_named(res) && has_out_fields) {
250250
out_fields <- c(out_fields, attr(res, "sf_column"))
251-
res_nm <- names(res)
252-
res <- res[, tolower(res_nm) %in% tolower(out_fields), drop = FALSE]
251+
match_nm <- match(tolower(out_fields), tolower(names(res)))
252+
res <- res[, match_nm[!is.na(match_nm)], drop = FALSE]
253253
}
254254

255255
if (rlang::is_empty(res)) {

0 commit comments

Comments
 (0)