Skip to content

Commit

Permalink
Merge pull request #335 from r-dbi/b-313-append-table-empty
Browse files Browse the repository at this point in the history
- `dbAppendTable()` shows a better error message if the input has zero columns (#313).
  • Loading branch information
krlmlr authored Jan 3, 2021
2 parents 2dbd61e + f9f21f9 commit 84c2bdb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/table-insert.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,15 @@ setMethod("sqlAppendTable", signature("DBIConnection"),
#' sqlAppendTableTemplate(ANSI(), "mtcars", mtcars, row.names = FALSE)
sqlAppendTableTemplate <- function(con, table, values, row.names = NA, prefix = "?", ..., pattern = "") {
if (missing(row.names)) {
warning("Do not rely on the default value of the row.names argument for sqlAppendTableTemplate(), it will change in the future.",
warning("Do not rely on the default value of the `row.names` argument to `sqlAppendTableTemplate()`, it will change in the future.",
call. = FALSE
)
}

if (length(values) == 0) {
stop("Must pass at least one column in `values`", call. = FALSE)
}

table <- dbQuoteIdentifier(con, table)

values <- sqlRownamesToColumn(values[0, , drop = FALSE], row.names)
Expand Down

0 comments on commit 84c2bdb

Please sign in to comment.