Skip to content

Commit

Permalink
Merge pull request #449 from tidyverse/dont-squash-dollar-call
Browse files Browse the repository at this point in the history
Don't squash accessor calls
  • Loading branch information
markfairbanks authored Sep 14, 2023
2 parents 505b751 + bc91005 commit 5328227
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

* `.by` no longer alters grouping in prior steps (#439)

* Arguments to `$` and `[[` calls are no longer prepended with `..` (#434)

# dtplyr 1.3.1

* Fix for failing R CMD check.
Expand Down
2 changes: 2 additions & 0 deletions R/tidyeval.R
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ dt_squash_call <- function(x, env, data, j = TRUE) {
x[[1]] <- expr(rleid)
x[-1] <- lapply(x[-1], dt_squash, env, data, j = j)
x
} else if (is_call(x, c("$", "[["))) {
x
} else {
x[-1] <- lapply(x[-1], dt_squash, env, data, j = j)
x
Expand Down
14 changes: 14 additions & 0 deletions tests/testthat/test-tidyeval.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ test_that("unless we're operating in the global environment", {
expect_equal(capture_dot(dt, !!quo, j = FALSE), quote(x + n))
})

test_that("ignores accessor calls, #434", {
df <- tibble(length = 1)

step <- lazy_dt(tibble(x = 1:3), "DT") %>%
mutate(y = df$length)

expect_equal(show_query(step), expr(copy(DT)[, `:=`(y = df$length)]))

step <- lazy_dt(tibble(x = 1:3), "DT") %>%
mutate(y = df[["length"]])

expect_equal(show_query(step), expr(copy(DT)[, `:=`(y = df[["length"]])]))
})

test_that("using environment of inlined quosures", {
dt <- lazy_dt(data.frame(x = 1:10, y = 1:10))

Expand Down

0 comments on commit 5328227

Please sign in to comment.