Skip to content

Commit

Permalink
Merge pull request #2099 from cynkra/f-1909-duck-auto
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr authored Oct 31, 2023
2 parents 1ce4b6d + 6d677ac commit 49fc205
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions R/dm_sql.R
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ ddl_quote_enum_col <- function(x, con) {
}

ddl_get_col_defs <- function(tables, con, table_names, pks) {
duckdb_auto_warned <- FALSE

get_sql_col_types <- function(tbl, name) {
# autoincrementing is not possible for composite keys, so `pk_col` is guaranteed
# to be a scalar
Expand Down Expand Up @@ -345,6 +347,15 @@ ddl_get_col_defs <- function(tables, con, table_names, pks) {
# DuckDB:
# Doesn't have a special data type. Uses `CREATE SEQUENCE` instead.
# Ref: https://duckdb.org/docs/sql/statements/create_sequence
# https://stackoverflow.com/a/72883259/946850
if (is_duckdb(con)) {
if (!duckdb_auto_warned) {
cli_warn(
"Autoincrementing columns not yet supported for DuckDB, these won't be set in the remote database but are preserved in the `dm`"
)
duckdb_auto_warned <<- TRUE
}
}

# SQLite:
# For a primary key, autoincrementing works by default, and it is almost never
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/_snaps/dm_sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

Code
dm_for_filter() %>% dm_sql(test_src_duckdb()$con)
Condition
Warning:
Autoincrementing columns not yet supported for DuckDB, these won't be set in the remote database but are preserved in the `dm`
Message
`on_delete = "cascade"` not supported for duckdb
Output
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/_snaps/duckdb.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

Code
dm_for_filter_df() %>% dm_sql(my_test_con())
Condition
Warning:
Autoincrementing columns not yet supported for DuckDB, these won't be set in the remote database but are preserved in the `dm`
Message
`on_delete = "cascade"` not supported for duckdb
Output
Expand Down

0 comments on commit 49fc205

Please sign in to comment.