Skip to content

Commit

Permalink
Merge pull request #75 from imanuelcostigan/fix-data-type-69
Browse files Browse the repository at this point in the history
- Test `dbDataType()` on connections (#69, #75, @imanuelcostigan).
  • Loading branch information
krlmlr committed Jun 8, 2016
2 parents c84f469 + 82c1f39 commit 5530e28
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
30 changes: 30 additions & 0 deletions R/test_connection.R
Expand Up @@ -29,6 +29,36 @@ test_connection <- function(skip = NULL, ctx = get_default_context()) {
expect_true(dbDisconnect(con))
},

#' \item{\code{data_type}}{
#' SQL Data types exist for all basic R data types. dbDataType() does not
#' throw an error and returns a nonempty atomic character
#' }
data_type = function() {
con <- connect(ctx)
check_conn_data_type <- function(value) {
eval(bquote({
expect_is(dbDataType(con, .(value)), "character")
expect_equal(length(dbDataType(con, .(value))), 1L)
expect_match(dbDataType(con, .(value)), ".")
}))
}

expect_conn_has_data_type <- function(value) {
eval(bquote(
expect_error(check_conn_data_type(.(value)), NA)))
}

expect_conn_has_data_type(logical(1))
expect_conn_has_data_type(integer(1))
expect_conn_has_data_type(numeric(1))
expect_conn_has_data_type(character(1))
expect_conn_has_data_type(Sys.Date())
expect_conn_has_data_type(Sys.time())
if (!isTRUE(ctx$tweaks$omit_blob_tests)) {
expect_conn_has_data_type(list(raw(1)))
}
},

#' \item{\code{cannot_disconnect_twice}}{
#' Repeated disconnect throws warning.
#' }
Expand Down
4 changes: 4 additions & 0 deletions man/test_connection.Rd

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

0 comments on commit 5530e28

Please sign in to comment.