Skip to content

Commit

Permalink
Merge branch 'r-0.8' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Mar 9, 2018
2 parents 505d187 + f828d44 commit 39b65ea
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 61 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ inst\/doc\/DBI\.b..$
^revdep/
^API$
^docs$
^man-roxygen$
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ after_script: R -q -e 'tic::after_script()'
language: r
sudo: false
cache: packages
latex: false
latex: true

#env
env:
Expand Down
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: DBI
Version: 0.7-15
Date: 2018-02-10
Version: 0.8
Date: 2018-02-24
Title: R Database Interface
Description: A database interface definition for communication
between R and relational database management systems. All
Expand Down Expand Up @@ -43,6 +43,7 @@ Collate:
'deprecated.R'
'hidden.R'
'interpolate.R'
'list-pairs.R'
'quote.R'
'rd.R'
'rownames.R'
Expand Down
58 changes: 37 additions & 21 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,56 @@
## DBI 0.7-15 (2018-02-10)
# DBI 0.8 (2018-02-24)

Breaking changes
----------------

- `SQL()` now strips the names from the output if the `names` argument is unset.
- The `dbReadTable()`, `dbWriteTable()`, `dbExistsTable()`, `dbRemoveTable()`, and `dbListFields()` generics now specialize over the first two arguments to support implementations with the `Id` S4 class as type for the second argument. Some packages may need to update their documentation to satisfy R CMD check again.

New generics
------------

- Schema support: Export `Id()`, new generics `dbListObjects()` and `dbUnquoteIdentifier()`, methods for `Id` that call `dbQuoteIdentifier()` and then forward (#220).
- `dbListConnections()` is soft-deprecated by documentation.
- New `dbQuoteLiteral()` generic. The default implementation uses switchpatch to avoid dispatch ambiguities, and forwards to `dbQuoteString()` for character vectors. Backends may override methods that also dispatch on the second argument, but in this case also an override for the `"SQL"` class is necessary (#172).

Default implementations
-----------------------

- Default implementations of `dbQuoteIdentifier()` and `dbQuoteLiteral()` preserve names, default implementation of `dbQuoteString()` strips names (#173).
- Breaking change: If the `names` argument is unset, `SQL()` strips the names from the output.
- Specialized methods for `dbQuoteString()` and `dbQuoteIdentifier()` are available again, for compatibility with clients that use `getMethod()` to access them (#218).
- Add default implementation of `dbListFields()`.
- The default implementation of `dbReadTable()` now has `row.names = FALSE` as default and also supports `row.names = NULL` (#186).

API changes
-----------

## DBI 0.7-14 (2018-01-27)
- The `SQL()` function gains an optional `names` argument which can be used to assign names to SQL strings.

- The `SQL()` function gains a `names` argument which can be used to assign names to SQL strings.
Deprecated generics
-------------------

- `dbListConnections()` is soft-deprecated by documentation.
- `dbListResults()` is deprecated by documentation (#58).
- `dbGetException()` is soft-deprecated by documentation (#51).
- Help pages for generics now contain a dynamic list of methods implemented by DBI backends (#162).
- `sqlInterpolate()` now supports both named and positional variables (#216, @hannesmuehleisen).
- Specialized methods for `dbQuoteString()` and `dbQuoteIdentifier()` are available again, for compatibility with clients that use `getMethod()` to access them (#218).

- The deprecated `print.list.pairs()` has been removed.

## DBI 0.7-13 (2017-11-27)
Bug fixes
---------

- The deprecated `print.list.pairs()` has been removed.
- Fix `dbDataType()` for `AsIs` object (#198, @yutannihilation).
- Point to db.rstudio.com (@wibeasley, #209).
- Reflect new 'r-dbi' organization in `DESCRIPTION` (@wibeasley, #207).
- Using switchpatch on the second argument for default implementations of `dbQuoteString()` and `dbQuoteIdentifier()`.
- New `dbQuoteLiteral()` generic. The default implementation uses switchpatch to avoid dispatch ambiguities, and forwards to `dbQuoteString()` for character vectors. Backends may override methods that also dispatch on the second argument, but in this case also an override for the `"SQL"` class is necessary (#172).
- Fix `dbQuoteString()` and `dbQuoteIdentifier()` to ignore invalid UTF-8 strings (r-dbi/DBItest#156).

Documentation
-------------

## DBI 0.7-12 (2017-08-10)

- Add default implementation of `dbListFields()`.

- Help pages for generics now contain a dynamic list of methods implemented by DBI backends (#162).
- `sqlInterpolate()` now supports both named and positional variables (#216, @hannesmuehleisen).
- Point to db.rstudio.com (@wibeasley, #209).
- Reflect new 'r-dbi' organization in `DESCRIPTION` (@wibeasley, #207).

## DBI 0.7-11 (2017-08-08)
Internal
--------

- The default implementation of `dbReadTable()` now has `row.names = FALSE` as default and also supports `row.names = NULL` (#186).
- Using switchpatch on the second argument for default implementations of `dbQuoteString()` and `dbQuoteIdentifier()`.


# DBI 0.7 (2017-06-17)
Expand Down
8 changes: 8 additions & 0 deletions R/list-pairs.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
print_list_pairs <- function(x, ...) {
for(key in names(x)){
value <- format(x[[key]])
if (identical(value, "")) next
cat(key, "=", value, "\n")
}
invisible(x)
}
40 changes: 26 additions & 14 deletions R/quote.R
Original file line number Diff line number Diff line change
Expand Up @@ -164,24 +164,30 @@ setMethod("dbQuoteIdentifier", signature("DBIConnection", "Id"), quote_identifie
#' @family DBIResult generics
#' @export
#' @examples
#' # Unquoting allows to understand the structure of a possibly complex quoted
#' # identifier
#' # Unquoting allows to understand the structure of a
#' # possibly complex quoted identifier
#' dbUnquoteIdentifier(
#' ANSI(),
#' SQL(c('"Schema"."Table"', '"UnqualifiedTable"'))
#' )
#'
#' # The returned object is always a list,
#' # also for Id objects or lists thereof
#' dbUnquoteIdentifier(
#' ANSI(),
#' SQL(c('"Schema"."Table"', "UnqualifiedTable"))
#' Id(schema = "Schema", table = "Table")
#' )
#'
#' # Character vectors are wrapped in a list
#' dbQuoteIdentifier(
#' dbUnquoteIdentifier(
#' ANSI(),
#' c(schema = "Schema", table = "Table")
#' list(Id(schema = "Schema", table = "Table"), Id(table = "UnqualifiedTable"))
#' )
#'
#' # Lists of character vectors are returned unchanged
#' dbQuoteIdentifier(
#' # Lists of SQL objects can also be processed,
#' # but each component must be length 1
#' dbUnquoteIdentifier(
#' ANSI(),
#' list(c(schema = "Schema", table = "Table"), "UnqualifiedTable")
#' list(SQL('"Schema"."Table"'), SQL('"UnqualifiedTable"'))
#' )
setGeneric("dbUnquoteIdentifier",
def = function(conn, x, ...) standardGeneric("dbUnquoteIdentifier")
Expand All @@ -196,7 +202,16 @@ setMethod("dbUnquoteIdentifier", signature("DBIConnection"), function(conn, x, .
if (is(x, "SQL")) {
split <- strsplit(as.character(x), '^"|"$|"[.]"')
components <- lapply(split, `[`, -1L)
tables <- lapply(components, Table)
lengths <- vapply(components, length, integer(1))
if (!all(lengths %in% 1:2)) {
stop("Can only unquote up to two components.", call. = FALSE)
}
named_components <- lapply(components, function(x) {
if (length(x) == 1) names(x) <- "table"
else names(x) <- c("schema", "table")
as.list(x)
})
tables <- lapply(named_components, do.call, what = Id)
quoted <- lapply(tables, dbQuoteIdentifier, conn = conn)
bad <- quoted != x
if (any(bad)) {
Expand All @@ -207,10 +222,7 @@ setMethod("dbUnquoteIdentifier", signature("DBIConnection"), function(conn, x, .
if (is(x, "Id")) {
return(list(x))
}
if (is.character(x)) {
return(list(do.call(Id, as.list(x))))
}
stop("x must be character, SQL or Table, or a list of such objects", call. = FALSE)
stop("x must be SQL or Table, or a list of such objects", call. = FALSE)
})

#' Quote literal strings
Expand Down
2 changes: 1 addition & 1 deletion R/table.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ setClass("Id", slots = list(name = "character"))
Id <- function(...) {
components <- c(...)
if (is.null(names(components)) || any(names(components) == "")) {
stop("All arguments to Table() must be named.", call. = FALSE)
stop("All arguments to Id() must be named.", call. = FALSE)
}
new("Id", name = components)
}
Expand Down
14 changes: 4 additions & 10 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
Minor update to support upcoming release of RSQLite.

## Test environments
* ubuntu 17.04 (local install), R 3.4.0
* ubuntu 12.04 (on travis-ci), R devel, release, and oldrel
* ubuntu 17.04 (local install), R 3.4.3
* ubuntu 14.04 (on travis-ci), R devel, release, and oldrel
* win-builder (release and devel)


## R CMD check results

0 errors | 0 warnings | 1 note

Found the following apparent S3 methods exported but not registered:
print.list.pairs

- print.list.pairs() has been deprecated and will be removed in the next release.

OK.

## Reverse dependencies

Checked all 157 downstream dependencies on CRAN and Bioconductor, no regressions found.
Checked more than 523 downstream dependencies on CRAN and Bioconductor, very few packages could not be installed or checked. Seeing new warnings in pool, RJDBC and RSQLServer, these packages need very minor documentation updates to accommodate changes to the definition of generics. Contacted maintaners of these packages.
24 changes: 15 additions & 9 deletions man/dbUnquoteIdentifier.Rd

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

4 changes: 1 addition & 3 deletions tic.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
get_stage("after_success") %>%
add_step(step_hello_world()) %>%
add_step(step_run_code(covr::codecov()))
add_package_checks()

get_stage("deploy") %>%
add_step(step_install_ssh_keys()) %>%
Expand Down

0 comments on commit 39b65ea

Please sign in to comment.