You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, I'd like to say thank you for addressing #95 with the latest release. Since then I have been running a bulk upsert process for a while now, and just now ran into a unique scenario that may be a potential bug.
Note I have been able to find a work around by passing combine_record_types =FALSE, and parsing the results myself, but I wanted to share this rare scenario. When receiving a single failed result with a NA column that's suppose to be a datetime, the type is a logical NA and the current method of converting datatypes does not work for rbindlist. However substituting the internal safe_bind_rows with dplyr::bind_rows does not fail.
records<-list(
successfulResults=tibble::tibble(Start_Time__c=anytime::anytime("2021-09-12T04:14:30Z", tz="UTC", asUTC=TRUE), B=1),
failedResults=tibble::tibble(Start_Time__c= as.logical(NA), B=1),
unprocessedRecords=tibble::tibble(Start_Time__c= as.character(), B= as.character())
)
# records <-statusbase_class_df<-records[[head(which.max(sapply(records, nrow)), 1)]]
# Second, convert the datatypes for any data.frames with zero rows# From StackOverflow post here: https://stackoverflow.com/a/47800157/5258043# distributed under the CC BY-SA 3.0 license terms.for (iin1:length(records)) {
if (nrow(records[[i]]) ==0) {
common<- names(records[[i]])[names(records[[i]]) %in% names(base_class_df)]
records[[i]][common] <- lapply(common, function(x) {
match.fun(paste0("as.", class(base_class_df[[x]])[1]))(records[[i]][[x]])
})
}
}
# Third, now bind them togetherres<-salesforcer::safe_bind_rows(records)
#> Error in rbindlist(l = l, fill = fill, idcol = idcol, ...): Class attribute on column 1 of item 2 does not match with column 1 of item 1.# res <- dplyr::bind_rows(records)
@JoshRosenstein Thanks for reporting! 🙏 I'll take a look. It's possible dplyr has improved its functionality latest. I remember wrestling quite a bit with NAs that turn into logicals and how to convert to the expected data type. It's odd to me that Salesforce doesn't provide metadata about the data types of the columns that are being returned by a query or CRUD operation like this.
Issue description
First of all, I'd like to say thank you for addressing #95 with the latest release. Since then I have been running a bulk upsert process for a while now, and just now ran into a unique scenario that may be a potential bug.
Note I have been able to find a work around by passing
combine_record_types =FALSE
, and parsing the results myself, but I wanted to share this rare scenario. When receiving a single failed result with a NA column that's suppose to be a datetime, the type is a logical NA and the current method of converting datatypes does not work for rbindlist. However substituting the internalsafe_bind_rows
withdplyr::bind_rows
does not fail.reprex
salesforcer/R/bulk-operation.R
Line 1283 in aef7aee
Session Info
The text was updated successfully, but these errors were encountered: