Skip to content

Commit ee3dab4

Browse files
committed
allow 64 bit integer person ids in cdmSubset
1 parent 589e2cb commit ee3dab4

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

R/cdmSubset.R

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,18 @@ cdmSample <- function(cdm,
261261
cdmSubset <- function(cdm, personId) {
262262

263263
checkmate::assertClass(cdm, "cdm_reference")
264-
checkmate::assertIntegerish(personId,
265-
min.len = 1,
266-
max.len = 1e6,
267-
null.ok = FALSE)
264+
265+
if (!methods::is(personId, "integer64")) {
266+
checkmate::assertIntegerish(personId,
267+
min.len = 1,
268+
max.len = 1e6,
269+
null.ok = FALSE)
270+
271+
personId <- as.integer(personId)
272+
} else {
273+
stopifnot(all(!is.na(personId)), length(personId) >= 1)
274+
}
275+
268276

269277
writeSchema <- cdmWriteSchema(cdm)
270278
if (is.null(writeSchema)) rlang::abort("write_schema is required for subsetting a cdm!")
@@ -273,7 +281,7 @@ cdmSubset <- function(cdm, personId) {
273281
prefix <- unique_prefix()
274282
DBI::dbWriteTable(con,
275283
name = .inSchema(writeSchema, glue::glue("temp{prefix}_"), dbms(con)),
276-
value = data.frame(person_id = as.integer(personId)),
284+
value = data.frame(person_id = personId),
277285
overwrite = TRUE)
278286

279287
# Note temporary = TRUE in dbWriteTable does not work on all dbms but we want a temp table here.

0 commit comments

Comments
 (0)