Skip to content

Commit

Permalink
Fixed dbFetch() for DBI drivers, no longer ignoring n argument.
Browse files Browse the repository at this point in the history
  • Loading branch information
Admin_mschuemi authored and Admin_mschuemi committed Nov 13, 2023
1 parent 650f49f commit 6f680df
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: DatabaseConnector
Type: Package
Title: Connecting to Various Database Platforms
Version: 6.3.0
Version: 6.3.1
Date: 2023-11-08
Authors@R: c(
person("Martijn", "Schuemie", email = "schuemie@ohdsi.org", role = c("aut", "cre")),
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
DatabaseConnector 6.3.1
=======================

Bugfixes:

1. Fixed `dbFetch()` for DBI drivers, no longer ignoring `n` argument.


DatabaseConnector 6.3.0
=======================

Expand Down
4 changes: 2 additions & 2 deletions R/DBI.R
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ setMethod("dbFetch", "DatabaseConnectorJdbcResult", function(res, n = -1, ...) {

#' @inherit DBI::dbFetch title description params details references return seealso
#' @export
setMethod("dbFetch", "DatabaseConnectorDbiResult", function(res, ...) {
columns <- DBI::dbFetch(res@resultSet, ...)
setMethod("dbFetch", "DatabaseConnectorDbiResult", function(res, n = -1, ...) {
columns <- DBI::dbFetch(res@resultSet, n, ...)
columns <- convertFields(res@dbms, columns)
columns <- dbFetchIntegerToNumeric(columns)
colnames(columns) <- tolower(colnames(columns))
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-fetchResults.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ for (testServer in testServers) {
)
expect_gt(dplyr::collect(andromeda$test2)$rowCount[1], 1)
Andromeda::close(andromeda)

# dbFetch only fetches n rows
sql <- "SELECT * FROM @cdm_database_schema.vocabulary;"
sql <- SqlRender::render(sql,
cdm_database_schema = cdmDatabaseSchema)
resultSet <- dbSendQuery(connection, sql)
data <- dbFetch(resultSet, n = 1)
dbClearResult(resultSet)
expect_equal(nrow(data), 1)
})
}

Expand Down

0 comments on commit 6f680df

Please sign in to comment.