Skip to content

Commit

Permalink
fix: checks for compatible keys on [[<-
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo committed Nov 15, 2023
1 parent 5f7509a commit 236c5f7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions R/join_keys.R
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,18 @@ c.join_key_set <- function(...) {
norm_value <- lapply(seq_along(value), function(.x) {
join_key(i, names(value)[.x], value[[.x]])
})
names(norm_value) <- names(value)

# Check if multiple modifications don't have a conflict
repeated_value_ix <- names(value) %in% names(value)[duplicated(names(value))]
repeated <- norm_value[repeated_value_ix]
vapply(
seq_along(repeated),
function(.ix, .x_value = repeated[[.ix]], .x_name = get_dataset_2(.x_value)) {
assert_compatible_keys(.x_value, repeated[-.ix][names(repeated[-.ix]) == .x_name])
},
logical(1)
)

norm_value <- lapply(norm_value, get_keys)
names(norm_value) <- names(value)
Expand Down Expand Up @@ -486,6 +498,7 @@ assert_compatible_keys2 <- function(x, y) {
assert_compatible_keys(x[idx_1], y[idx_2])
}
}
TRUE
}

#' Helper function to assert if two key sets contain incompatible keys
Expand Down

0 comments on commit 236c5f7

Please sign in to comment.