Skip to content

Commit

Permalink
:=NULL together with i is now an error
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdowle committed Jul 25, 2014
1 parent 2a4f7b1 commit 00284c6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ We moved from R-Forge to GitHub on 9 June 2014, including history.
DT[,.(colB,colC,colD)] # same
```
Similarly, `by=.()` is now a shortcut for `by=list()`, for consistency with `i` and `j`.
28. `DT[where, someCol:=NULL]` is now an error that i is provided since it makes no sense to delete a column for only a subset of rows.
Expand Down
5 changes: 5 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -4900,10 +4900,15 @@ test(1352.6, DT[,sum(b),by=.(a%%2)], DT[,sum(b),by=a%%2])
test(1352.7, DT[,sum(b),by=.(Grp=a%%2)], DT[,sum(b),by=list(Grp=a%%2)])
test(1352.8, DT[,sum(b),by=.(a%%2,c)], DT[,sum(b),by=list(a%%2,c)])

# that :=NULL together with i is now an error
DT = data.table(a=1:3, b=1:6)
test(1353.1, DT[2, b:=NULL], error="When deleting columns, i should not be provided")
test(1353.2, DT[2, c("a","b"):=list(42, NULL)], error="When deleting columns, i should not be provided")

##########################



# TO DO: Add test for fixed bug #5519 - dcast.data.table returned error when a package imported data.table, but dint happen when "depends" on data.table. This is fixed (commit 1263 v1.9.3), but not sure how to add test.

# TO DO: test and highlight in docs that negatives are fine and fast in forderv (ref R wish #15644)
Expand Down
1 change: 1 addition & 0 deletions src/assign.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ SEXP assign(SEXP dt, SEXP rows, SEXP cols, SEXP newcolnames, SEXP values, SEXP v
else
thisvalue = values; // One vector applied to all columns, often NULL or NA for example
if (TYPEOF(thisvalue)==NILSXP) {
if (!isNull(rows)) error("When deleting columns, i should not be provided");
anytodelete = TRUE;
continue; // delete column(s) afterwards, below this loop
}
Expand Down

0 comments on commit 00284c6

Please sign in to comment.