Skip to content

Commit

Permalink
restore specialized methods for dbQuoteString() and dbQuoteIdentifier…
Browse files Browse the repository at this point in the history
…(), closes #218

- Specialized methods for `dbQuoteString()` and `dbQuoteIdentifier()` are available again, for compatibility with clients that use `getMethod()` to access them (#218).
  • Loading branch information
krlmlr committed Jan 25, 2018
1 parent 97a7d75 commit d4fe97d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 12 deletions.
38 changes: 30 additions & 8 deletions R/quote.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ setGeneric("dbQuoteIdentifier",
def = function(conn, x, ...) standardGeneric("dbQuoteIdentifier")
)

#' @rdname hidden_aliases
#' @export
setMethod("dbQuoteIdentifier", "DBIConnection",
quote_identifier <-
function(conn, x, ...) {
if (is(x, "SQL")) return(x)
if (is(x, "Table")) {
Expand All @@ -110,7 +108,20 @@ setMethod("dbQuoteIdentifier", "DBIConnection",
SQL(paste('"', x, '"', sep = ""))
}
}
)

#' @rdname hidden_aliases
#' @export
setMethod("dbQuoteIdentifier", c("DBIConnection"), quote_identifier)

# Need to keep other method declarations around for now, because clients might
# use getMethod(), see e.g. https://github.com/r-dbi/odbc/pull/149
#' @rdname hidden_aliases
#' @export
setMethod("dbQuoteIdentifier", c("DBIConnection", "character"), quote_identifier)

#' @rdname hidden_aliases
#' @export
setMethod("dbQuoteIdentifier", c("DBIConnection", "SQL"), quote_identifier)

#' Quote literal strings
#'
Expand Down Expand Up @@ -147,9 +158,7 @@ setGeneric("dbQuoteString",
def = function(conn, x, ...) standardGeneric("dbQuoteString")
)

#' @rdname hidden_aliases
#' @export
setMethod("dbQuoteString", "DBIConnection",
quote_string <-
function(conn, x, ...) {
if (is(x, "SQL")) return(x)
if (!is.character(x)) stop("x must be character or SQL", call. = FALSE)
Expand All @@ -167,7 +176,20 @@ setMethod("dbQuoteString", "DBIConnection",
SQL(str)
}
}
)

# Need to keep other method declarations around for now, because clients might
# use getMethod(), see e.g. https://github.com/r-dbi/odbc/pull/149
#' @rdname hidden_aliases
#' @export
setMethod("dbQuoteString", c("DBIConnection"), quote_string)

#' @rdname hidden_aliases
#' @export
setMethod("dbQuoteString", c("DBIConnection", "character"), quote_string)

#' @rdname hidden_aliases
#' @export
setMethod("dbQuoteString", c("DBIConnection", "SQL"), quote_string)

#' Quote literal values
#'
Expand Down
4 changes: 4 additions & 0 deletions R/table.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ Table <- function(...) {
setMethod("show", "Table", function(object) {
cat("<Table> ", paste0(object@name, collapse = "."), "\n", sep = "")
})

#' @rdname hidden_aliases
#' @export
setMethod("dbQuoteIdentifier", c("DBIConnection", "Table"), quote_identifier)
23 changes: 19 additions & 4 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 d4fe97d

Please sign in to comment.