Skip to content

Commit 77e100d

Browse files
committed
Merge branch 'r-0.7-14' into production
2 parents 3e63790 + 1ce5639 commit 77e100d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+813
-293
lines changed

API

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Exported functions
44

55
ANSI()
6-
SQL(x)
6+
SQL(x, ..., names = NULL)
77
SQLKeywords(dbObj, ...)
88
dbBegin(conn, ...)
99
dbBind(res, params, ...)

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: DBI
2-
Version: 0.7-13
3-
Date: 2017-11-27
2+
Version: 0.7-14
3+
Date: 2018-01-27
44
Title: R Database Interface
55
Description: A database interface definition for communication
66
between R and relational database management systems. All
@@ -43,6 +43,7 @@ Collate:
4343
'hidden.R'
4444
'interpolate.R'
4545
'quote.R'
46+
'rd.R'
4647
'rownames.R'
4748
'table-create.R'
4849
'table-insert.R'

NEWS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## DBI 0.7-14 (2018-01-27)
2+
3+
- The `SQL()` function gains a `names` argument which can be used to assign names to SQL strings.
4+
- `dbListResults()` is deprecated by documentation (#58).
5+
- `dbGetException()` is soft-deprecated by documentation (#51).
6+
- Help pages for generics now contain a dynamic list of methods implemented by DBI backends (#162).
7+
- `sqlInterpolate()` now supports both named and positional variables (#216, @hannesmuehleisen).
8+
- Specialized methods for `dbQuoteString()` and `dbQuoteIdentifier()` are available again, for compatibility with clients that use `getMethod()` to access them (#218).
9+
10+
111
## DBI 0.7-13 (2017-11-27)
212

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

R/DBConnection.R

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ setMethod("show", "DBIConnection", function(object) {
3434
# RPostgreSQL)
3535
tryCatch(
3636
show_connection(object),
37-
error = function(e) NULL)
37+
error = function(e) NULL
38+
)
3839
invisible(NULL)
3940
})
4041

@@ -50,6 +51,9 @@ show_connection <- function(object) {
5051
#' This closes the connection, discards all pending work, and frees
5152
#' resources (e.g., memory, sockets).
5253
#'
54+
#' @template methods
55+
#' @templateVar method_name dbDisconnect
56+
#'
5357
#' @inherit DBItest::spec_connection_disconnect return
5458
#' @inheritSection DBItest::spec_connection_disconnect Specification
5559
#'
@@ -83,6 +87,10 @@ setGeneric("dbDisconnect",
8387
#' and transfer them piecemeal to R, others may transfer all the data to the
8488
#' client -- but not necessarily to the memory that R manages. See individual
8589
#' drivers' `dbSendQuery()` documentation for details.
90+
#'
91+
#' @template methods
92+
#' @templateVar method_name dbSendQuery
93+
#'
8694
#' @inherit DBItest::spec_result_send_query return
8795
#' @inheritSection DBItest::spec_result_send_query Specification
8896
#'
@@ -120,6 +128,9 @@ setGeneric("dbSendQuery",
120128
#' forwards to [dbSendQuery()], to support backends that only
121129
#' implement the latter.
122130
#'
131+
#' @template methods
132+
#' @templateVar method_name dbSendStatement
133+
#'
123134
#' @inherit DBItest::spec_result_send_statement return
124135
#' @inheritSection DBItest::spec_result_send_statement Specification
125136
#'
@@ -168,6 +179,9 @@ setMethod(
168179
#' reasons. However, callers are strongly advised to use
169180
#' [dbExecute()] for data manipulation statements.
170181
#'
182+
#' @template methods
183+
#' @templateVar method_name dbGetQuery
184+
#'
171185
#' @inherit DBItest::spec_result_get_query return
172186
#' @inheritSection DBItest::spec_result_get_query Specification
173187
#'
@@ -213,6 +227,9 @@ setMethod("dbGetQuery", signature("DBIConnection", "character"),
213227
#' [dbSendStatement()], then [dbGetRowsAffected()], ensuring that
214228
#' the result is always free-d by [dbClearResult()].
215229
#'
230+
#' @template methods
231+
#' @templateVar method_name dbExecute
232+
#'
216233
#' @section Implementation notes:
217234
#' Subclasses should override this method only if they provide some sort of
218235
#' performance optimization.
@@ -251,6 +268,9 @@ setMethod(
251268

252269
#' Get DBMS exceptions
253270
#'
271+
#' DEPRECATED. Backends should use R's condition system to signal errors and
272+
#' warnings.
273+
#'
254274
#' @inheritParams dbGetQuery
255275
#' @family DBIConnection generics
256276
#' @return a list with elements `errorNum` (an integer error number) and
@@ -263,7 +283,9 @@ setGeneric("dbGetException",
263283

264284
#' A list of all pending results
265285
#'
266-
#' List of [DBIResult-class] objects currently active on the connection.
286+
#' DEPRECATED. DBI currenty supports only one open result set per connection,
287+
#' you need to keep track of the result sets you open if you need this
288+
#' functionality.
267289
#'
268290
#' @inheritParams dbGetQuery
269291
#' @family DBIConnection generics
@@ -296,10 +318,16 @@ setGeneric("dbListFields",
296318

297319
#' @rdname hidden_aliases
298320
#' @export
299-
setMethod("dbListFields", c("DBIConnection", "character"),
321+
setMethod("dbListFields", signature("DBIConnection", "character"),
300322
function(conn, name, ...) {
301-
rs <- dbSendQuery(conn, paste("SELECT * FROM ",
302-
dbQuoteIdentifier(conn, name), "LIMIT 0"))
323+
rs <- dbSendQuery(
324+
conn,
325+
paste(
326+
"SELECT * FROM ",
327+
dbQuoteIdentifier(conn, name),
328+
"LIMIT 0"
329+
)
330+
)
303331
on.exit(dbClearResult(rs))
304332

305333
names(dbFetch(rs, n = 0, row.names = FALSE))
@@ -312,6 +340,9 @@ setMethod("dbListFields", c("DBIConnection", "character"),
312340
#' connection.
313341
#' This should, where possible, include temporary tables, and views.
314342
#'
343+
#' @template methods
344+
#' @templateVar method_name dbListTables
345+
#'
315346
#' @inherit DBItest::spec_sql_list_tables return
316347
#' @inheritSection DBItest::spec_sql_list_tables Additional arguments
317348
#'
@@ -337,6 +368,9 @@ setGeneric("dbListTables",
337368
#' a column to row names and converting the column names to valid
338369
#' R identifiers.
339370
#'
371+
#' @template methods
372+
#' @templateVar method_name dbReadTable
373+
#'
340374
#' @inherit DBItest::spec_sql_read_table return
341375
#' @inheritSection DBItest::spec_sql_read_table Additional arguments
342376
#' @inheritSection DBItest::spec_sql_read_table Specification
@@ -388,6 +422,9 @@ setMethod("dbReadTable", c("DBIConnection", "character"),
388422
#' Writes, overwrites or appends a data frame to a database table, optionally
389423
#' converting row names to a column and specifying SQL data types for fields.
390424
#'
425+
#' @template methods
426+
#' @templateVar method_name dbWriteTable
427+
#'
391428
#' @inherit DBItest::spec_sql_write_table return
392429
#' @inheritSection DBItest::spec_sql_write_table Additional arguments
393430
#' @inheritSection DBItest::spec_sql_write_table Specification
@@ -422,6 +459,9 @@ setGeneric("dbWriteTable",
422459
#'
423460
#' Returns if a table given by name exists in the database.
424461
#'
462+
#' @template methods
463+
#' @templateVar method_name dbExistsTable
464+
#'
425465
#' @inherit DBItest::spec_sql_exists_table return
426466
#' @inheritSection DBItest::spec_sql_exists_table Additional arguments
427467
#' @inheritSection DBItest::spec_sql_exists_table Specification
@@ -448,6 +488,9 @@ setGeneric("dbExistsTable",
448488
#' Remove a remote table (e.g., created by [dbWriteTable()])
449489
#' from the database.
450490
#'
491+
#' @template methods
492+
#' @templateVar method_name dbRemoveTable
493+
#'
451494
#' @inherit DBItest::spec_sql_remove_table return
452495
#' @inheritSection DBItest::spec_sql_remove_table Specification
453496
#'

R/DBDriver.R

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ setClass("DBIDriver", contains = c("DBIObject", "VIRTUAL"))
5555
#' @export
5656
setGeneric("dbDriver",
5757
def = function(drvName, ...) standardGeneric("dbDriver"),
58-
valueClass = "DBIDriver")
58+
valueClass = "DBIDriver"
59+
)
5960

6061
#' @rdname hidden_aliases
61-
setMethod("dbDriver", "character",
62+
setMethod("dbDriver", signature("character"),
6263
definition = function(drvName, ...) {
6364
findDriver(drvName)(...)
6465
}
@@ -72,7 +73,8 @@ setMethod("show", "DBIDriver", function(object) {
7273
# to protect drivers that fail to implement the required methods (e.g.,
7374
# RPostgreSQL)
7475
show_driver(object),
75-
error = function(e) NULL)
76+
error = function(e) NULL
77+
)
7678
invisible(NULL)
7779
})
7880

@@ -99,11 +101,13 @@ findDriver <- function(drvName) {
99101
}
100102

101103
# Can't find it:
102-
stop("Couldn't find driver ", drvName, ". Looked in:\n",
104+
stop(
105+
"Couldn't find driver ", drvName, ". Looked in:\n",
103106
"* global namespace\n",
104107
"* in package called ", drvName, "\n",
105108
"* in package called ", pkgName,
106-
call. = FALSE)
109+
call. = FALSE
110+
)
107111
}
108112

109113
get2 <- function(x, env) {
@@ -134,6 +138,9 @@ setGeneric("dbUnloadDriver",
134138
#' The authentication mechanism is left unspecified, so check the
135139
#' documentation of individual drivers for details.
136140
#'
141+
#' @template methods
142+
#' @templateVar method_name dbConnect
143+
#'
137144
#' @inherit DBItest::spec_driver_connect return
138145
#' @inheritSection DBItest::spec_driver_connect Specification
139146
#'
@@ -196,6 +203,9 @@ setGeneric("dbListConnections",
196203
#' Notice that many DBMS do not follow IEEE arithmetic, so there are potential
197204
#' problems with under/overflows and loss of precision.
198205
#'
206+
#' @template methods
207+
#' @templateVar method_name dbDataType
208+
#'
199209
#' @inherit DBItest::spec_driver_data_type return
200210
#' @inheritSection DBItest::spec_driver_data_type Specification
201211
#' @inheritSection DBItest::spec_result_create_table_with_data_type Specification

R/DBObject.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,17 @@ setClass("DBIObject", "VIRTUAL")
7474
#' @return a named list
7575
#' @export
7676
setGeneric("dbGetInfo",
77-
def = function(dbObj, ...) standardGeneric("dbGetInfo")
77+
def = function(dbObj, ...) standardGeneric("dbGetInfo")
7878
)
7979

8080
#' Is this DBMS object still valid?
8181
#'
8282
#' This generic tests whether a database object is still valid (i.e. it hasn't
8383
#' been disconnected or cleared).
8484
#'
85+
#' @template methods
86+
#' @templateVar method_name dbIsValid
87+
#'
8588
#' @inherit DBItest::spec_meta_is_valid return
8689
#'
8790
#' @inheritParams dbGetInfo
@@ -105,7 +108,8 @@ setGeneric("dbGetInfo",
105108
#' dbIsValid(con)
106109
setGeneric("dbIsValid",
107110
def = function(dbObj, ...) standardGeneric("dbIsValid"),
108-
valueClass = "logical")
111+
valueClass = "logical"
112+
)
109113

110114
setGeneric("summary")
111115
setMethod("summary", "DBIObject", function(object, ...) {

R/DBResult.R

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ setMethod("show", "DBIResult", function(object) {
2929
# RPostgreSQL)
3030
tryCatch(
3131
show_result(object),
32-
error = function(e) NULL)
32+
error = function(e) NULL
33+
)
3334
invisible(NULL)
3435
})
3536

3637
show_result <- function(object) {
3738
cat("<", is(object)[1], ">\n", sep = "")
38-
if(!dbIsValid(object)){
39+
if (!dbIsValid(object)) {
3940
cat("EXPIRED\n")
4041
} else {
4142
cat(" SQL ", dbGetStatement(object), "\n", sep = "")
@@ -56,6 +57,9 @@ show_result <- function(object) {
5657
#' implementation for `dbFetch()` calls `fetch()` so that it is compatible with
5758
#' existing code. Modern backends should implement for `dbFetch()` only.
5859
#'
60+
#' @template methods
61+
#' @templateVar method_name dbFetch
62+
#'
5963
#' @inherit DBItest::spec_result_fetch return
6064
#' @inheritSection DBItest::spec_result_fetch Specification
6165
#' @inheritSection DBItest::spec_result_roundtrip Specification
@@ -114,6 +118,9 @@ setGeneric("fetch",
114118
#' cases (e.g., very large result sets) this can be a critical step to avoid
115119
#' exhausting resources (memory, file descriptors, etc.)
116120
#'
121+
#' @template methods
122+
#' @templateVar method_name dbClearResult
123+
#'
117124
#' @inherit DBItest::spec_result_clear_result return
118125
#' @inheritSection DBItest::spec_result_clear_result Specification
119126
#'
@@ -167,6 +174,9 @@ setGeneric("dbColumnInfo",
167174
#' Returns the statement that was passed to [dbSendQuery()]
168175
#' or [dbSendStatement()].
169176
#'
177+
#' @template methods
178+
#' @templateVar method_name dbGetStatement
179+
#'
170180
#' @inherit DBItest::spec_meta_get_statement return
171181
#'
172182
#' @inheritParams dbClearResult
@@ -193,6 +203,9 @@ setGeneric("dbGetStatement",
193203
#' A `SELECT` query is completed if all rows have been fetched.
194204
#' A data manipulation statement is always completed.
195205
#'
206+
#' @template methods
207+
#' @templateVar method_name dbHasCompleted
208+
#'
196209
#' @inherit DBItest::spec_meta_has_completed return
197210
#' @inheritSection DBItest::spec_meta_has_completed Specification
198211
#'
@@ -224,6 +237,9 @@ setGeneric("dbHasCompleted",
224237
#' This method returns the number of rows that were added, deleted, or updated
225238
#' by a data manipulation statement.
226239
#'
240+
#' @template methods
241+
#' @templateVar method_name dbGetRowsAffected
242+
#'
227243
#' @inherit DBItest::spec_meta_get_rows_affected return
228244
#'
229245
#' @inheritParams dbClearResult
@@ -250,6 +266,9 @@ setGeneric("dbGetRowsAffected",
250266
#' Returns the total number of rows actually fetched with calls to [dbFetch()]
251267
#' for this result set.
252268
#'
269+
#' @template methods
270+
#' @templateVar method_name dbGetRowCount
271+
#'
253272
#' @inherit DBItest::spec_meta_get_row_count return
254273
#'
255274
#' @inheritParams dbClearResult
@@ -327,6 +346,9 @@ setMethod("dbGetInfo", "DBIResult", function(dbObj, ...) {
327346
#' - `$1` (positional matching by index) in \pkg{RPostgres} and \pkg{RSQLite}
328347
#' - `:name` and `$name` (named matching) in \pkg{RSQLite}
329348
#'
349+
#' @template methods
350+
#' @templateVar method_name dbBind
351+
#'
330352
#' @inherit DBItest::spec_meta_bind return
331353
#' @inheritSection DBItest::spec_meta_bind Specification
332354
#'

0 commit comments

Comments
 (0)