Skip to content

Commit

Permalink
Argument tweaking
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Dec 12, 2023
1 parent b3292be commit 8424780
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion R/Connection.R
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ setMethod(
#' @inheritParams DBI::dbFetch
#' @export
setMethod("dbGetQuery", signature("OdbcConnection", "character"),
function(conn, statement, n = -1, params = NULL, timeout = Inf, ...) {
function(conn, statement, ..., n = -1, params = NULL, timeout = Inf) {
rs <- dbSendQuery(conn, statement, params = params, timeout = timeout, ...)
on.exit(dbClearResult(rs))

Expand Down
10 changes: 7 additions & 3 deletions R/Result.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ OdbcResult <- function(connection, statement, params = NULL, immediate = FALSE,
if (nzchar(connection@encoding)) {
statement <- enc2iconv(statement, connection@encoding)
}

if (is.infinite(timeout)) {
timeout <- 0
timeout <- 0L
}

ptr <- new_result(connection@ptr, statement, immediate, timeout)
ptr <- new_result(
p = connection@ptr,
sql = statement,
immediate = immediate,
timeout = timeout
)
res <- new("OdbcResult", connection = connection, statement = statement, ptr = ptr)

if (!is.null(params)) {
Expand Down
2 changes: 1 addition & 1 deletion man/OdbcConnection.Rd

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

2 comments on commit 8424780

@Odraio
Copy link

@Odraio Odraio commented on 8424780 Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @hadley, thank you for fixing and improving the pull request! One question: shouldn't the ... (variadic function) always be the last parameter in the Connection.R file? I would like to learn from these changes.

@hadley
Copy link
Member Author

@hadley hadley commented on 8424780 Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We generally believe it should go after required arguments. See https://design.tidyverse.org/dots-after-required.html for details.

Please sign in to comment.