-
Notifications
You must be signed in to change notification settings - Fork 991
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
set() that does not update any rows should still add cols #5409
Comments
set of tests dt = data.table(a=1L)
test(1, set(copy(dt), 0L, "b", logical(0)), data.table(a=1L, b=NA))
test(1, set(copy(dt), NA_integer_, "b", NA), data.table(a=1L, b=NA))
test(1, set(copy(dt), NA_integer_, "b", logical(0)), copy(dt)[0L, b := logical(0)])
test(1, set(copy(dt), 0L, "b", NA), copy(dt)[NA, b := NA]) Maybe we should rewrite |
I've been trying to figure this one out. The Lines 382 to 384 in 4e6ad97
But for the AFAIU, when Lines 388 to 392 in 4e6ad97
This causes the behavior above as when we pass in I figured that this was able to be solved by checking whether we call from Lines 404 to 413 in 4e6ad97
I was able to pass all tests (listed above and old ones) by adding an additional check for if (!length(newcolnames) && !isString(cols)) { // return early if no new columns to be added and called from ':='
*_Last_updated = 0;
UNPROTECT(protecti);
return(dt); // all items of rows either 0 or NA. !length(newcolnames) for #759
} So what I'm wondering is, does |
I would expect
set(x, i, j, val)
to work similarly tox[i, j := val]
orx[i, j] <- val
for integeri
. However, there is a discrepancy wheni
is0L
: While<-
and:=
add missing columns,set()
does not.vs.
sessionInfo()
The text was updated successfully, but these errors were encountered: