From 125d40405f516ab62ef7cf5b97fcda88d7f36ab0 Mon Sep 17 00:00:00 2001 From: mattdowle Date: Mon, 11 Oct 2021 14:33:45 -0600 Subject: [PATCH 1/2] retain nomatch=FALSE for backwards compatibility --- R/data.table.R | 4 ++-- inst/tests/tests.Rraw | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/R/data.table.R b/R/data.table.R index 91f7b52110..aaa6e4bc38 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -221,8 +221,8 @@ replace_dot_alias = function(e) { # TO DO (document/faq/example). Removed for now ... if ((roll || rolltolast) && missing(mult)) mult="last" # for when there is exact match to mult. This does not control cases where the roll is mult, that is always the last one. .unsafe.opt() #3585 missingnomatch = missing(nomatch) - nomatch0 = identical(nomatch,0) || identical(nomatch,0L) # for warning with row-numbers in i; #4353 - if (nomatch0) nomatch=NULL # retain nomatch=0 backwards compatibility; #857 + nomatch0 = identical(nomatch,0) || identical(nomatch,0L) || identical(nomatch, FALSE) # for warning with row-numbers in i; #4353 + if (nomatch0) nomatch=NULL # retain nomatch=0|FALSE backwards compatibility, #857 #XXXX if (!(is.null(nomatch) || (length(nomatch)==1L && is.na(nomatch)))) stopf("nomatch= must be either NA or NULL (or 0 for backwards compatibility which is the same as NULL but please use NULL)") if (!is.logical(which) || length(which)>1L) stopf("which= must be a logical vector length 1. Either FALSE, TRUE or NA.") if ((isTRUE(which)||is.na(which)) && !missing(j)) stopf("which==%s (meaning return row numbers) but j is also supplied. Either you need row numbers or the result of j, but only one type of result can be returned.", which) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index c814b9f397..fab8321f88 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -18271,3 +18271,7 @@ DT = data.table(A=1:3) class(DT) = "data.table" test(2222, print(DT), output="A.*3") +# retain nomatch=FALSE backwards compatibility +DT = data.table(A=1:3, key="A") +test(2223, DT[.(4), nomatch=FALSE], data.table(A=integer(), key="A")) + From 0ef4c72da4f5ab5d58bb2729c7962719ca3dc442 Mon Sep 17 00:00:00 2001 From: mattdowle Date: Mon, 11 Oct 2021 14:41:42 -0600 Subject: [PATCH 2/2] add PR number now that's known --- R/data.table.R | 2 +- inst/tests/tests.Rraw | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/data.table.R b/R/data.table.R index aaa6e4bc38..3fe2ba8e1f 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -222,7 +222,7 @@ replace_dot_alias = function(e) { .unsafe.opt() #3585 missingnomatch = missing(nomatch) nomatch0 = identical(nomatch,0) || identical(nomatch,0L) || identical(nomatch, FALSE) # for warning with row-numbers in i; #4353 - if (nomatch0) nomatch=NULL # retain nomatch=0|FALSE backwards compatibility, #857 #XXXX + if (nomatch0) nomatch=NULL # retain nomatch=0|FALSE backwards compatibility, #857 #5214 if (!(is.null(nomatch) || (length(nomatch)==1L && is.na(nomatch)))) stopf("nomatch= must be either NA or NULL (or 0 for backwards compatibility which is the same as NULL but please use NULL)") if (!is.logical(which) || length(which)>1L) stopf("which= must be a logical vector length 1. Either FALSE, TRUE or NA.") if ((isTRUE(which)||is.na(which)) && !missing(j)) stopf("which==%s (meaning return row numbers) but j is also supplied. Either you need row numbers or the result of j, but only one type of result can be returned.", which) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index fab8321f88..18fb5c82a5 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -18271,7 +18271,7 @@ DT = data.table(A=1:3) class(DT) = "data.table" test(2222, print(DT), output="A.*3") -# retain nomatch=FALSE backwards compatibility +# retain nomatch=FALSE backwards compatibility, #5214 DT = data.table(A=1:3, key="A") test(2223, DT[.(4), nomatch=FALSE], data.table(A=integer(), key="A"))