Skip to content

Commit

Permalink
Document dbListTables and dbListFields together (#655)
Browse files Browse the repository at this point in the history
And inherit less from DBI in order to avoid confusing text. Mostly taken from #618. Fixes #645

Drop aliases for other DBI functions
  • Loading branch information
hadley authored Dec 8, 2023
1 parent ed37a13 commit b46f6cc
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 200 deletions.
56 changes: 34 additions & 22 deletions R/Connection.R
Original file line number Diff line number Diff line change
Expand Up @@ -506,45 +506,57 @@ setMethod(
"dbQuoteIdentifier", c("OdbcConnection", "SQL"),
getMethod("dbQuoteIdentifier", c("DBIConnection", "SQL"), asNamespace("DBI")))

#' @inherit DBI::dbListTables
#' @param catalog_name The name of the catalog to return, the default returns all catalogs.
#' @param schema_name The name of the schema to return, the default returns all schemas.
#' @param table_name The name of the table to return, the default returns all tables.
#' List remote tables and fields for an ODBC connection
#'
#' `dbListTables()` provides names of remote tables accessible through this
#' connection; `dbListFields()` provides names of columns within a table.
#'
#' @inheritParams DBI::dbListTables
#' @param catalog_name,schema_name,table_name Catalog, schema, and table names.
#'
#' Use `%` as a wildcard to match any name; use `_` to any any character.
#' @param table_type The type of the table to return, the default returns all table types.
#' @aliases dbListTables
#' @details
#' \code{\%} can be used as a wildcard in any of the search parameters to
#' match 0 or more characters. `_` can be used to match any single character.
#' @seealso The ODBC documentation on [Pattern Value Arguments](https://docs.microsoft.com/en-us/sql/odbc/reference/develop-app/pattern-value-arguments)
#' for further details on the supported syntax.
#' @returns A character vector of table or field names respectively.
#' @export
setMethod(
"dbListTables", "OdbcConnection",
function(conn, catalog_name = NULL, schema_name = NULL, table_name = NULL,
table_type = NULL, ...) {

odbcConnectionTables(conn,
function(conn,
catalog_name = NULL,
schema_name = NULL,
table_name = NULL,
table_type = NULL,
...) {

odbcConnectionTables(
conn,
name = table_name,
catalog_name = catalog_name,
schema_name = schema_name,
table_type = table_type)$table_name
table_type = table_type
)$table_name
})

#' @inherit DBI::dbListFields
#' @rdname dbListTables-OdbcConnection-method
#' @inheritParams DBI::dbListFields
#' @aliases dbListFields
#' @inheritParams dbListTables,OdbcConnection-method
#' @param column_name The name of the column to return, the default returns all columns.
#' @inherit dbListTables,OdbcConnection-method details
#' @export
setMethod(
"dbListFields", c("OdbcConnection", "character"),
function(conn, name, catalog_name = NULL, schema_name = NULL, column_name = NULL, ...) {
odbcConnectionColumns(conn,
function(
conn,
name,
catalog_name = NULL,
schema_name = NULL,
column_name = NULL,
...
) {
odbcConnectionColumns(
conn,
name = name,
catalog_name = catalog_name,
schema_name = schema_name,
column_name = column_name)[["name"]]
column_name = column_name
)[["name"]]
})

#' @rdname OdbcConnection
Expand Down
1 change: 0 additions & 1 deletion R/Driver.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ setMethod(
#' * [Microsoft's "Introduction to ODBC"](https://learn.microsoft.com/en-us/sql/odbc/reference)
#' is a thorough resource on the ODBC interface.
#'
#' @aliases dbConnect
#' @import rlang
#' @export
setMethod(
Expand Down
1 change: 0 additions & 1 deletion R/db.R
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ setMethod("isTempTable", c("Microsoft SQL Server", "character"),
#' Therefore, in all cases query for \code{name___%}.
#' @rdname SQLServer
#' @docType methods
#' @aliases dbExistsTable
#' @inherit DBI::dbExistsTable
#' @usage NULL
setMethod(
Expand Down
1 change: 0 additions & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ reference:
- title: DBI methods
contents:
- 'dbConnect,OdbcDriver-method'
- 'dbListFields,OdbcConnection,character-method'
- 'dbListTables,OdbcConnection-method'
- 'DBI-tables'

Expand Down
1 change: 0 additions & 1 deletion man/SQLServer.Rd

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

1 change: 0 additions & 1 deletion man/dbConnect-OdbcDriver-method.Rd

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

121 changes: 0 additions & 121 deletions man/dbListFields-OdbcConnection-character-method.Rd

This file was deleted.

80 changes: 28 additions & 52 deletions man/dbListTables-OdbcConnection-method.Rd

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

0 comments on commit b46f6cc

Please sign in to comment.