From 0b74909b605f230fd117e709b2a1de02e770ab37 Mon Sep 17 00:00:00 2001 From: bbimber Date: Wed, 20 May 2026 15:06:45 -0700 Subject: [PATCH 1/5] Support bigint --- Rlabkey/DESCRIPTION | 2 +- Rlabkey/R/makeDF.R | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Rlabkey/DESCRIPTION b/Rlabkey/DESCRIPTION index fe58ab1..d3a97f1 100755 --- a/Rlabkey/DESCRIPTION +++ b/Rlabkey/DESCRIPTION @@ -18,6 +18,6 @@ Description: The 'LabKey' client library for R makes it easy for R users to License: Apache License 2.0 Copyright: Copyright (c) 2010-2018 LabKey Corporation LazyLoad: true -Depends: httr, jsonlite +Depends: httr, jsonlite, bit64 LinkingTo: Rcpp Imports: Rcpp (>= 0.11.0) diff --git a/Rlabkey/R/makeDF.R b/Rlabkey/R/makeDF.R index 7be7a9c..c3229b3 100755 --- a/Rlabkey/R/makeDF.R +++ b/Rlabkey/R/makeDF.R @@ -147,7 +147,7 @@ makeDF <- function(rawdata, colSelect=NULL, showHidden, colNameOpt) try( if(mod=="date") { newdat[,j] <- .parseDate(newdat[,j])} else if(mod=="string"){ suppressWarnings(mode(newdat[,j]) <- "character")} else - if(mod=="int"){ suppressWarnings(mode(newdat[,j]) <- "integer")} else + if(mod=="int"){ suppressWarnings(newdat[,j] <- bit64::as.integer64(newdat[,j]))} else if(mod=="boolean"){suppressWarnings(mode(newdat[,j]) <- "logical")} else if(mod=="float"){suppressWarnings(mode(newdat[,j]) <- "numeric")} else {print("MetaData field type not recognized.")} @@ -163,7 +163,7 @@ makeDF <- function(rawdata, colSelect=NULL, showHidden, colNameOpt) try( if(mod=="date"){ newdat <- .parseDate(newdat)}else if(mod=="string"){suppressWarnings(mode(newdat) <- "character")} else - if(mod=="int"){ suppressWarnings(mode(newdat) <- "integer")} else + if(mod=="int"){ suppressWarnings(newdat[,j] <- bit64::as.integer64(newdat[,j]))} else if(mod=="boolean"){suppressWarnings(mode(newdat) <- "logical")} else if(mod=="float"){suppressWarnings(mode(newdat) <- "numeric")} else {print("MetaData field type not recognized.")} From b1bdc7778a43b4b1171c8047d369a123c5cc5f09 Mon Sep 17 00:00:00 2001 From: bbimber Date: Wed, 24 Jun 2026 13:35:41 -0700 Subject: [PATCH 2/5] Properly handle empty strings Switch Depends -> Imports --- Rlabkey/DESCRIPTION | 4 ++-- Rlabkey/R/makeDF.R | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Rlabkey/DESCRIPTION b/Rlabkey/DESCRIPTION index d3a97f1..b797163 100755 --- a/Rlabkey/DESCRIPTION +++ b/Rlabkey/DESCRIPTION @@ -18,6 +18,6 @@ Description: The 'LabKey' client library for R makes it easy for R users to License: Apache License 2.0 Copyright: Copyright (c) 2010-2018 LabKey Corporation LazyLoad: true -Depends: httr, jsonlite, bit64 +Depends: httr, jsonlite LinkingTo: Rcpp -Imports: Rcpp (>= 0.11.0) +Imports: Rcpp (>= 0.11.0), bit64 diff --git a/Rlabkey/R/makeDF.R b/Rlabkey/R/makeDF.R index c3229b3..acb404d 100755 --- a/Rlabkey/R/makeDF.R +++ b/Rlabkey/R/makeDF.R @@ -14,6 +14,11 @@ # limitations under the License. ## +safe_as_integer64 <- function(x) { + x[x == ""] <- NA + bit64::as.integer64(x) +} + makeDF <- function(rawdata, colSelect=NULL, showHidden, colNameOpt) { decode <- fromJSON(rawdata, simplifyVector=FALSE, simplifyDataFrame=FALSE) @@ -147,7 +152,7 @@ makeDF <- function(rawdata, colSelect=NULL, showHidden, colNameOpt) try( if(mod=="date") { newdat[,j] <- .parseDate(newdat[,j])} else if(mod=="string"){ suppressWarnings(mode(newdat[,j]) <- "character")} else - if(mod=="int"){ suppressWarnings(newdat[,j] <- bit64::as.integer64(newdat[,j]))} else + if(mod=="int"){ suppressWarnings(newdat[,j] <- safe_as_integer64(newdat[,j]))} else if(mod=="boolean"){suppressWarnings(mode(newdat[,j]) <- "logical")} else if(mod=="float"){suppressWarnings(mode(newdat[,j]) <- "numeric")} else {print("MetaData field type not recognized.")} @@ -163,7 +168,7 @@ makeDF <- function(rawdata, colSelect=NULL, showHidden, colNameOpt) try( if(mod=="date"){ newdat <- .parseDate(newdat)}else if(mod=="string"){suppressWarnings(mode(newdat) <- "character")} else - if(mod=="int"){ suppressWarnings(newdat[,j] <- bit64::as.integer64(newdat[,j]))} else + if(mod=="int"){ suppressWarnings(newdat[,j] <- safe_as_integer64(newdat[,j]))} else if(mod=="boolean"){suppressWarnings(mode(newdat) <- "logical")} else if(mod=="float"){suppressWarnings(mode(newdat) <- "numeric")} else {print("MetaData field type not recognized.")} From b7da35ae11a49d9a34b77b35ad693dbada7316c8 Mon Sep 17 00:00:00 2001 From: bbimber Date: Thu, 25 Jun 2026 10:41:23 -0700 Subject: [PATCH 3/5] Another attempt to handle bit64/NAs --- Rlabkey/R/makeDF.R | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Rlabkey/R/makeDF.R b/Rlabkey/R/makeDF.R index acb404d..160fdb6 100755 --- a/Rlabkey/R/makeDF.R +++ b/Rlabkey/R/makeDF.R @@ -14,9 +14,20 @@ # limitations under the License. ## +MAX_INT <- .Machine$integer.max +MIN_INT <- -MAX_INT - 1 safe_as_integer64 <- function(x) { x[x == ""] <- NA - bit64::as.integer64(x) + if (any(x > MAX_INT | x < MIN_INT, na.rm = T)) { + x <- bit64::as.integer64(x) + + # NOTE: any NAs will be bit64::NA_integer64_ + if (all(is.na(x))) { + return(as.integer(x)) + } + } + + return(x) } makeDF <- function(rawdata, colSelect=NULL, showHidden, colNameOpt) From a89298471d69bf6ac7c36d5e58ffa432ba185e80 Mon Sep 17 00:00:00 2001 From: bbimber Date: Thu, 25 Jun 2026 10:50:00 -0700 Subject: [PATCH 4/5] Another attempt to handle bit64/NAs --- Rlabkey/R/makeDF.R | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Rlabkey/R/makeDF.R b/Rlabkey/R/makeDF.R index 160fdb6..17960b2 100755 --- a/Rlabkey/R/makeDF.R +++ b/Rlabkey/R/makeDF.R @@ -20,14 +20,9 @@ safe_as_integer64 <- function(x) { x[x == ""] <- NA if (any(x > MAX_INT | x < MIN_INT, na.rm = T)) { x <- bit64::as.integer64(x) - - # NOTE: any NAs will be bit64::NA_integer64_ - if (all(is.na(x))) { - return(as.integer(x)) - } } - return(x) + return(as.integer(x)) } makeDF <- function(rawdata, colSelect=NULL, showHidden, colNameOpt) From fe7ed9187af8d31b04cd54d518ecba92f5cd4cb1 Mon Sep 17 00:00:00 2001 From: bbimber Date: Thu, 25 Jun 2026 10:50:58 -0700 Subject: [PATCH 5/5] Another attempt to handle bit64/NAs --- Rlabkey/R/makeDF.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rlabkey/R/makeDF.R b/Rlabkey/R/makeDF.R index 17960b2..ff6faef 100755 --- a/Rlabkey/R/makeDF.R +++ b/Rlabkey/R/makeDF.R @@ -19,7 +19,7 @@ MIN_INT <- -MAX_INT - 1 safe_as_integer64 <- function(x) { x[x == ""] <- NA if (any(x > MAX_INT | x < MIN_INT, na.rm = T)) { - x <- bit64::as.integer64(x) + return(bit64::as.integer64(x)) } return(as.integer(x))