Skip to content

Commit

Permalink
Fix #124: Correct handling of imports with serial numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
akbertram committed Jul 1, 2024
1 parent be655fa commit 3749255
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion R/import.R
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ matchRecordIdsByKey <- function(schema, data, fieldIds, fieldValues) {
keys <- which(fieldIds %in% keyFieldIds)

provided <- as.data.frame(fieldValues[keys])
if(ncol(provided) != length(keyFieldIds)) {
stop("One or more key fields are missing")
}
names(provided) <- sprintf("k%d", seq_along(keyFieldIds))

# Check that our input does not include duplicates according to the key
Expand All @@ -316,7 +319,7 @@ matchRecordIdsByKey <- function(schema, data, fieldIds, fieldValues) {

findKeyFieldIds <- function(schema) {
fieldIds <- sapply(schema$elements, function(e) e$id)
keys <- sapply(schema$elements, function(e) identical(e$key, TRUE))
keys <- sapply(schema$elements, function(e) identical(e$key, TRUE) && e$type != "serial")

return(fieldIds[keys])
}
Expand Down

0 comments on commit 3749255

Please sign in to comment.