From fd68b129ca7619fbc8092b8a296193dcee1604e0 Mon Sep 17 00:00:00 2001 From: markfairbanks Date: Tue, 12 Sep 2023 11:12:38 -0500 Subject: [PATCH 1/7] Ignore calls to `$` --- R/tidyeval.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/tidyeval.R b/R/tidyeval.R index 5a954cfb..2863c3e4 100644 --- a/R/tidyeval.R +++ b/R/tidyeval.R @@ -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, "$") && !is_mask_pronoun(x)) { + x } else { x[-1] <- lapply(x[-1], dt_squash, env, data, j = j) x From 9c039565f61a2d413a149e651f2c8625919e58f1 Mon Sep 17 00:00:00 2001 From: markfairbanks Date: Tue, 12 Sep 2023 11:12:46 -0500 Subject: [PATCH 2/7] Add test --- tests/testthat/test-tidyeval.R | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/testthat/test-tidyeval.R b/tests/testthat/test-tidyeval.R index db068b56..c732f437 100644 --- a/tests/testthat/test-tidyeval.R +++ b/tests/testthat/test-tidyeval.R @@ -33,6 +33,15 @@ test_that("unless we're operating in the global environment", { expect_equal(capture_dot(dt, !!quo, j = FALSE), quote(x + n)) }) +test_that("ignores calls to `$`, #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)])) +}) + test_that("using environment of inlined quosures", { dt <- lazy_dt(data.frame(x = 1:10, y = 1:10)) From 5a1ded3cdc6bf5df331582fc26e32e0af6d5b452 Mon Sep 17 00:00:00 2001 From: markfairbanks Date: Tue, 12 Sep 2023 11:12:52 -0500 Subject: [PATCH 3/7] News bullet --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 33b6d0ca..5724c5cd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -19,6 +19,8 @@ * `.by` no longer alters grouping in prior steps (#439) +* Arguments to `$` calls are no longer prepended with `..` (#434) + # dtplyr 1.3.1 * Fix for failing R CMD check. From c0fc810651868af4fea0b0f3da90eb4c60c8da28 Mon Sep 17 00:00:00 2001 From: markfairbanks Date: Tue, 12 Sep 2023 11:22:40 -0500 Subject: [PATCH 4/7] Ignore brackets --- R/tidyeval.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/tidyeval.R b/R/tidyeval.R index 2863c3e4..0b4bffdf 100644 --- a/R/tidyeval.R +++ b/R/tidyeval.R @@ -270,7 +270,7 @@ 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, "$") && !is_mask_pronoun(x)) { + } else if (is_call(x, c("$", "[[")) && !is_mask_pronoun(x)) { x } else { x[-1] <- lapply(x[-1], dt_squash, env, data, j = j) From 51c45ae4902179d7008ab160039f416a748229b3 Mon Sep 17 00:00:00 2001 From: markfairbanks Date: Tue, 12 Sep 2023 11:22:54 -0500 Subject: [PATCH 5/7] Add test --- tests/testthat/test-tidyeval.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-tidyeval.R b/tests/testthat/test-tidyeval.R index c732f437..d79ae47f 100644 --- a/tests/testthat/test-tidyeval.R +++ b/tests/testthat/test-tidyeval.R @@ -33,13 +33,18 @@ test_that("unless we're operating in the global environment", { expect_equal(capture_dot(dt, !!quo, j = FALSE), quote(x + n)) }) -test_that("ignores calls to `$`, #434", { +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", { From 5a70b41ef4dc2609a59232cf8431b387b80b4fc6 Mon Sep 17 00:00:00 2001 From: markfairbanks Date: Tue, 12 Sep 2023 11:23:24 -0500 Subject: [PATCH 6/7] Adjust news bullet --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 5724c5cd..5c4d9d76 100644 --- a/NEWS.md +++ b/NEWS.md @@ -19,7 +19,7 @@ * `.by` no longer alters grouping in prior steps (#439) -* Arguments to `$` calls are no longer prepended with `..` (#434) +* Arguments to `$` and `[[` calls are no longer prepended with `..` (#434) # dtplyr 1.3.1 From bc91005458771e153990feda4d3df87d5aadd2ac Mon Sep 17 00:00:00 2001 From: markfairbanks Date: Thu, 14 Sep 2023 10:29:07 -0600 Subject: [PATCH 7/7] Remove mask check --- R/tidyeval.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/tidyeval.R b/R/tidyeval.R index 0b4bffdf..f84c2e89 100644 --- a/R/tidyeval.R +++ b/R/tidyeval.R @@ -270,7 +270,7 @@ 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("$", "[[")) && !is_mask_pronoun(x)) { + } else if (is_call(x, c("$", "[["))) { x } else { x[-1] <- lapply(x[-1], dt_squash, env, data, j = j)