Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# dbplyr (development version)

* Fixed overwrite flag in `copy_to()` to work when source is in the same DB as destination (@liudvikasakelis, #1535)
* Snowflake correctly translates `$` to `:` (@jsowder, #1608)
* `dbplyr_uncount()` now works with Redshift (@owenjonesuob, #1601).

Expand Down
2 changes: 2 additions & 0 deletions R/verb-compute.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ compute.tbl_sql <- function(
x,
name = NULL,
temporary = TRUE,
overwrite = FALSE,
unique_indexes = list(),
indexes = list(),
analyze = TRUE,
Expand Down Expand Up @@ -67,6 +68,7 @@ compute.tbl_sql <- function(
name,
sql,
temporary = temporary,
overwrite = overwrite,
unique_indexes = unique_indexes,
indexes = indexes,
analyze = analyze,
Expand Down
1 change: 1 addition & 0 deletions R/verb-copy-to.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ copy_to.src_sql <- function(
df,
name = name,
temporary = temporary,
overwrite = overwrite,
unique_indexes = unique_indexes,
indexes = indexes,
analyze = analyze,
Expand Down
5 changes: 5 additions & 0 deletions man/collapse.tbl_sql.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions tests/testthat/test-verb-copy-to.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ test_that("only overwrite existing table if explicitly requested", {
expect_silent(copy_to(con, data.frame(x = 1), name = "df", overwrite = TRUE))
})

test_that("overwrite flag works when copying *within* db sources", {
con <- local_sqlite_connection()
df <- copy_to(con, tibble(x = 1), "df", temporary = FALSE)
copy_to(con, df, "df2", temporary = FALSE)

df2 <- tibble(x = 2)
out <- copy_to(con, df2, name = "df2", temporary = FALSE, overwrite = TRUE)
expect_equal(collect(out), df2)
})

test_that("can create a new table in non-default schema", {
con <- local_sqlite_con_with_aux()

Expand Down
Loading