Skip to content

Commit

Permalink
Fix Rdatatable#4981: don't trust all.vars when its arguments contains…
Browse files Browse the repository at this point in the history
… get/eval and siblings.
  • Loading branch information
OfekShilon committed May 8, 2021
1 parent 10463e3 commit f2d037f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion R/data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,14 @@ replace_dot_alias = function(e) {
bysub = parse(text=paste0("list(",paste(bysub,collapse=","),")"))[[1L]]
bysubl = as.list.default(bysub)
}
allbyvars = intersect(all.vars(bysub), names_x)
# Fix 4981: when the 'by' expression includes get/mget/eval, all.vars
# cannot be trusted to infer all used columns
bysub.elems <- rapply(as.list(bysub), as.character)
if (any(c("eval","evalq","eval.parent","local","get","mget","dynGet") %chin% bysub.elems))
allbyvars = NULL
else
allbyvars = intersect(all.vars(bysub), names_x)

orderedirows = .Call(CisOrderedSubset, irows, nrow(x)) # TRUE when irows is NULL (i.e. no i clause). Similar but better than is.sorted(f__)
bysameorder = byindex = FALSE
if (!bysub %iscall% ":" && ##Fix #4285
Expand Down

0 comments on commit f2d037f

Please sign in to comment.