Skip to content

sf_query error related to flatten_tbl_df #130

Description

@tpsteiner

Issue description

I tried using sf_query today to get license history data in salesforce, and received the error below. Hoping someone could help.

soql <- "SELECT
	ParentId,
	CreatedById,
	CreatedDate,
	Field,
	OldValue,
	NewValue
FROM
  License__History
WHERE
  ParentId IN ('a3x8V000001yCL9QAM','a3x8V000002bFSmQAM')"

sf_data <- salesforcer::sf_query(soql, guess_types = FALSE)

Error in `dplyr::bind_rows()`:
! Can't combine `..1$NewValue` <character> and `..7$NewValue` <logical>.
Run `rlang::last_trace()` to see where the error occurred. 

Some debugging led me to salesforcer::flatten_tbl_df, which may be the culprit.

Below is the resultset just before the function is run. Note that the field "OldValue" only appears in the first record, which may be the issue.

resultset_sample <- list(list(ParentId = "a3x8V000002dLNCQA2", 
                              CreatedById = "0058V00000DtVfJQAV", 
                              CreatedDate = "2023-05-22T13:10:14.000+0000", 
                              Field = "Active_upon_creation__c", 
                              OldValue = FALSE, 
                              NewValue = TRUE), 
                         list(ParentId = "a3x8V000002ZmcaQAC", 
                              CreatedById = "0058V00000DtGk4QAF", 
                              CreatedDate = "2023-04-13T20:34:33.000+0000", 
                              Field = "Current_Contract__c", 
                              NewValue = "8008V00000Hcwb2QAB"))

salesforcer::flatten_tbl_df(resultset_sample)

Error in `as_tibble_row()`:
! Column names `ParentId`, `CreatedById`, `CreatedDate`, `Field`, and `NewValue` must not be duplicated.
Use `.name_repair` to specify repair.
Caused by error in `repaired_names()`:
! Names must be unique.These names are duplicated:
  * "ParentId" at locations 1 and 7.
  * "CreatedById" at locations 2 and 8.
  * "CreatedDate" at locations 3 and 9.
  * "Field" at locations 4 and 10.
  * "NewValue" at locations 6 and 11.


Session Info

> devtools::session_info()
─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.3.1 (2023-06-16 ucrt)
 os       Windows 11 x64 (build 22631)
 system   x86_64, mingw32
 ui       RStudio
 language (EN)
 collate  English_United States.utf8
 ctype    English_United States.utf8
 tz       America/Denver
 date     2024-03-08
 rstudio  2023.12.1+402 Ocean Storm (desktop)
 pandoc   2.19.2 @ C:\\PROGRA~1\\Pandoc\\pandoc.exePackages ───────────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version     date (UTC) lib source
 anytime       0.3.9       2020-08-27 [1] CRAN (R 4.3.1)
 askpass       1.2.0       2023-09-03 [1] CRAN (R 4.3.2)
 base64enc     0.1-3       2015-07-28 [1] CRAN (R 4.3.0)
 cachem        1.0.8       2023-05-01 [1] CRAN (R 4.3.0)
 cli           3.6.2       2023-12-11 [1] CRAN (R 4.3.3)
 crayon        1.5.2       2022-09-29 [1] CRAN (R 4.3.0)
 curl          5.2.1       2024-03-01 [1] CRAN (R 4.3.3)
 data.table    1.15.2      2024-02-29 [1] CRAN (R 4.3.3)
 devtools      2.4.5       2022-10-11 [1] CRAN (R 4.3.0)
 digest        0.6.34      2024-01-11 [1] CRAN (R 4.3.3)
 dplyr         1.1.4       2023-11-17 [1] CRAN (R 4.3.2)
 ellipsis      0.3.2       2021-04-29 [1] CRAN (R 4.3.0)
 fansi         1.0.6       2023-12-08 [1] CRAN (R 4.3.3)
 fastmap       1.1.1       2023-02-24 [1] CRAN (R 4.3.0)
 fs            1.6.3       2023-07-20 [1] CRAN (R 4.3.3)
 generics      0.1.3       2022-07-05 [1] CRAN (R 4.3.0)
 glue          1.7.0       2024-01-09 [1] CRAN (R 4.3.3)
 hms           1.1.3       2023-03-21 [1] CRAN (R 4.3.0)
 htmltools     0.5.7       2023-11-03 [1] CRAN (R 4.3.3)
 htmlwidgets   1.6.4       2023-12-06 [1] CRAN (R 4.3.2)
 httpuv        1.6.14      2024-01-26 [1] CRAN (R 4.3.3)
 httr          1.4.7       2023-08-15 [1] CRAN (R 4.3.2)
 jsonlite      1.8.8       2023-12-04 [1] CRAN (R 4.3.3)
 later         1.3.2       2023-12-06 [1] CRAN (R 4.3.3)
 lifecycle     1.0.4       2023-11-07 [1] CRAN (R 4.3.1)
 lubridate     1.9.3       2023-09-27 [1] CRAN (R 4.3.3)
 magrittr      2.0.3       2022-03-30 [1] CRAN (R 4.3.0)
 memoise       2.0.1       2021-11-26 [1] CRAN (R 4.3.0)
 mime          0.12        2021-09-28 [1] CRAN (R 4.3.0)
 miniUI        0.1.1.1     2018-05-18 [1] CRAN (R 4.3.0)
 openssl       2.1.1       2023-09-25 [1] CRAN (R 4.3.3)
 pillar        1.9.0       2023-03-22 [1] CRAN (R 4.3.0)
 pkgbuild      1.4.3       2023-12-10 [1] CRAN (R 4.3.2)
 pkgconfig     2.0.3       2019-09-22 [1] CRAN (R 4.3.0)
 pkgload       1.3.4       2024-01-16 [1] CRAN (R 4.3.2)
 profvis       0.3.8       2023-05-02 [1] CRAN (R 4.3.3)
 promises      1.2.1       2023-08-10 [1] CRAN (R 4.3.3)
 purrr         1.0.2       2023-08-10 [1] CRAN (R 4.3.3)
 R6            2.5.1       2021-08-19 [1] CRAN (R 4.3.0)
 Rcpp          1.0.12      2024-01-09 [1] CRAN (R 4.3.3)
 readr         2.1.5       2024-01-10 [1] CRAN (R 4.3.3)
 remotes       2.4.2.1     2023-07-18 [1] CRAN (R 4.3.2)
 rjson         0.2.21      2022-01-09 [1] CRAN (R 4.3.1)
 rlang         1.1.3       2024-01-10 [1] CRAN (R 4.3.3)
 rlist         0.4.6.2     2021-09-03 [1] CRAN (R 4.3.1)
 rstudioapi    0.15.0      2023-07-07 [1] CRAN (R 4.3.2)
 salesforcer   1.0.1       2022-03-01 [1] CRAN (R 4.3.1)
 sessioninfo   1.2.2       2021-12-06 [1] CRAN (R 4.3.0)
 shiny         1.8.0       2023-11-17 [1] CRAN (R 4.3.2)
 stringi       1.8.3       2023-12-11 [1] CRAN (R 4.3.2)
 stringr       1.5.1       2023-11-14 [1] CRAN (R 4.3.2)
 tibble        3.2.1       2023-03-20 [1] CRAN (R 4.3.0)
 tidyselect    1.2.0       2022-10-10 [1] CRAN (R 4.3.0)
 timechange    0.3.0       2024-01-18 [1] CRAN (R 4.3.3)
 tzdb          0.4.0       2023-05-12 [1] CRAN (R 4.3.1)
 urlchecker    1.0.1       2021-11-30 [1] CRAN (R 4.3.0)
 usethis       2.2.3       2024-02-19 [1] CRAN (R 4.3.3)
 utf8          1.2.4       2023-10-22 [1] CRAN (R 4.3.3)
 vctrs         0.6.5       2023-12-01 [1] CRAN (R 4.3.3)
 XML           3.99-0.16.1 2024-01-22 [1] CRAN (R 4.3.2)
 xml2          1.3.6       2023-12-04 [1] CRAN (R 4.3.3)
 xtable        1.8-4       2019-04-21 [1] CRAN (R 4.3.0)
 zip           2.3.1       2024-01-27 [1] CRAN (R 4.3.3)

 [1] C:/Users/thomas.steiner/AppData/Local/R/win-library/4.3
 [2] C:/Program Files/R/R-4.3.1/library

Metadata

Metadata

Labels

bugUnintended behavior that should be correctedquestion or helpClarification or help may suffice to resolve

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions