sicarul / rpostgresql

Automatically exported from code.google.com/p/rpostgresql
0 stars 0 forks source link

postgresqlQuoteId should not quote * #72

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
postgresqlQuoteId wraps identifiers such as column names in double quotes.

It would be useful if an exception was made for an input of *, since this 
should not be quoted.  Currently, it is necessary to write code like:

ifelse(identifiers == "*", identifiers, postgresqlQuoteId(identifiers))

Current implementation:

postgresqlQuoteId <- function(identifiers) 
{
    ret <- paste("\"", gsub("\"", "\"\"", identifiers), "\"", 
        sep = "")
    ret
}

Suggested new implementation:

postgresqlQuoteId <- function(identifiers) 
{
    ifelse(
      identifiers == "*", 
      identifiers, 
      paste0('"', gsub('"', '""', identifiers), '"')
    )
}

Original issue reported on code.google.com by richiero...@gmail.com on 9 Dec 2014 at 10:14