[R-sig-DB] dbWriteTable and dbReadTable generics

Hadley Wickham h@w|ckh@m @end|ng |rom gm@||@com
Fri Oct 18 18:56:19 CEST 2013


Hi all,

So far I have made a number of minor changes to DBI (as described in
https://github.com/rstats-db/DBI/blob/master/NEWS), currently none of
which should break DBI dependencies.

I'd like to discuss one small change that will require changes in some
dependencies: updating the arguments to dbWriteTable and dbReadTable.
Currently the generics look like:

setGeneric("dbWriteTable",
  def = function(conn, name, value, ...) standardGeneric("dbWriteTable"),
  valueClass = "logical"
)

setGeneric("dbReadTable",
  def = function(conn, name, ...) standardGeneric("dbReadTable"),
  valueClass = "data.frame"
)

but the documentation also describes a number of additional arguments
that are implemented by the majority of packages: row.names, overwrite
and append. I'd like to move these to the generics to get:

setGeneric("dbWriteTable",
  def = function(conn, name, value, row.names = FALSE,
                       overwrite = FALSE, append = FALSE, ...) {
     standardGeneric("dbWriteTable")
  }, valueClass = "logical"
)

setGeneric("dbReadTable",
  def = function(conn, name, row.names = FALSE, ...) {
    standardGeneric("dbReadTable")
  },
  valueClass = "data.frame"
)

I'd also suggest a change to the semantics of row.names. It should be:

* TRUE to use the row.names column
* FALSE to not use row names
* a character string to specify an alternative column to use for row names

I think this is close to the currently convention, but it is not well
documented.

This will require a small amount of work for any maintainers who
currently don't implement these options.

I'll also be careful when handling any future cran releases of DBI -
all downstream maintainers will get a heads up at least a month before
submission before CRAN so you'll have time to make any changes without
cran breathing down your neck.

Hadley

-- 
Chief Scientist, RStudio
http://had.co.nz/




More information about the R-sig-DB mailing list