Skip to content

Commit

Permalink
Merge pull request #1714 from cynkra/f-1642-bulk-insert
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Dec 25, 2022
2 parents 20c9900 + a01ed8b commit e70bdc8
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions R/rows-dm.R
Expand Up @@ -297,21 +297,9 @@ do_rows_append <- function(x, y, by = NULL, ..., in_place = FALSE, autoinc_col =

insert_sql <- map_chr(insert_queries, dbplyr::sql_render)

# Didn't work on Postgres
if (FALSE) {
returning_map_sql <- paste0(
"SELECT ", DBI::dbQuoteLiteral(con, key_values), " AS ", autoinc_col_orig, ", ",
autoinc_col, " FROM (",
insert_sql,
") q"
)

returning_sql <- paste(returning_map_sql, collapse = "\nUNION ALL\n")

DBI::dbGetQuery(con, returning_sql, immediate = TRUE)
}

# Run INSERT INTO queries, side effect!
# Must run queries individually, e.g. on Postgres:
# > WITH clause containing a data-modifying statement must be at the top level
insert_res <- map(insert_queries, ~ DBI::dbGetQuery(con, .x))

out <- tibble(
Expand Down

0 comments on commit e70bdc8

Please sign in to comment.