R/dbQuoteString_PqConnection_character.R

Defines functions dbQuoteString_PqConnection_character

Documented in dbQuoteString_PqConnection_character

#' @rdname quote
#' @usage NULL
dbQuoteString_PqConnection_character <- function(conn, x, ...) {
  if (length(x) == 0) return(SQL(character()))
  if (is(conn, "RedshiftConnection")) {
    out <- paste0("'", gsub("(['\\\\])", "\\1\\1", enc2utf8(x)), "'")
    out[is.na(x)] <- "NULL::varchar(max)"
  } else {
    out <- connection_quote_string(conn@ptr, enc2utf8(x))
  }
  SQL(out)
}

#' @rdname quote
#' @export
setMethod("dbQuoteString", c("PqConnection", "character"), dbQuoteString_PqConnection_character)

Try the RPostgres package in your browser

Any scripts or data that you put into this service are public.

RPostgres documentation built on Oct. 23, 2023, 1:06 a.m.