Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for duplicate names when supplying character literals #367

Merged
merged 4 commits into from
Oct 28, 2024

Conversation

lionel-
Copy link
Member

@lionel- lionel- commented Oct 25, 2024

Closes #346.

@@ -18,36 +18,12 @@ vars_select_eval <- function(vars,
return(pos)
}

uniquely_named <- uniquely_named %||% is.data.frame(data)

if (!is_symbolic(wrapped)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this early exit for literals so that all inputs go through the same path via the tidyselect interpreter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a very good idea for consistency

@@ -301,11 +277,6 @@ chr_as_locations <- function(x, vars, call = caller_env(), arg = NULL) {
set_names(out, names(x))
}

as_indices <- function(x, vars, strict = TRUE, call) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was unused.

internal <- data_mask$.__tidyselect__.$internal

if (internal$uniquely_named && is_character(expr)) {
# Since tidyselect allows repairing data frames with duplicate names by
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully this comment is clear 😬

@lionel- lionel- requested a review from DavisVaughan October 25, 2024 10:39
vars_split <- vctrs::vec_split(seq_along(vars), vars)

# Mark data duplicates so we can fail instead of disambiguating them
# when renaming
uniquely_named <- uniquely_named %||% is.data.frame(data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I didn't know the uniqueness check behavior depended on whether or not the input was a data frame vs like a named list or named character vector

@@ -18,36 +18,12 @@ vars_select_eval <- function(vars,
return(pos)
}

uniquely_named <- uniquely_named %||% is.data.frame(data)

if (!is_symbolic(wrapped)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a very good idea for consistency

@lionel- lionel- force-pushed the bugfix/duplicate-check branch from 1d54d2d to 9f75fb9 Compare October 28, 2024 12:55
@lionel- lionel- merged commit 4005748 into main Oct 28, 2024
11 checks passed
@lionel- lionel- deleted the bugfix/duplicate-check branch October 28, 2024 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

eval_select names validation depends on type of expr
2 participants