Skip to content

Commit

Permalink
default implementation for dbListFields(DBIConnection, Id)
Browse files Browse the repository at this point in the history
- Add default implementation for `dbListFields(DBIConnection, Id)`, this relies on `dbQuoteIdentifier(DBIConnection, Id)` (#75).
  • Loading branch information
krlmlr committed Apr 23, 2018
1 parent 861eeb8 commit bee20c9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
32 changes: 22 additions & 10 deletions R/DBConnection.R
Original file line number Diff line number Diff line change
Expand Up @@ -324,20 +324,32 @@ setGeneric("dbListFields",
#' @export
setMethod("dbListFields", signature("DBIConnection", "character"),
function(conn, name, ...) {
rs <- dbSendQuery(
conn,
paste(
"SELECT * FROM ",
dbQuoteIdentifier(conn, name),
"LIMIT 0"
)
)
on.exit(dbClearResult(rs))
list_fields(conn, name)
}
)

names(dbFetch(rs, n = 0, row.names = FALSE))
#' @rdname hidden_aliases
#' @export
setMethod("dbListFields", signature("DBIConnection", "Id"),
function(conn, name, ...) {
list_fields(conn, name)
}
)

list_fields <- function(conn, name) {
rs <- dbSendQuery(
conn,
paste(
"SELECT * FROM ",
dbQuoteIdentifier(conn, name),
"LIMIT 0"
)
)
on.exit(dbClearResult(rs))

names(dbFetch(rs, n = 0, row.names = FALSE))
}

#' List remote tables
#'
#' Returns the unquoted names of remote tables accessible through this
Expand Down
3 changes: 3 additions & 0 deletions man/hidden_aliases.Rd

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

0 comments on commit bee20c9

Please sign in to comment.