% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dbUnquoteIdentifier.R
\name{dbUnquoteIdentifier}
\alias{dbUnquoteIdentifier}
\title{Unquote identifiers}
\usage{
dbUnquoteIdentifier(conn, x, ...)
}
\arguments{
\item{conn}{A \linkS4class{DBIConnection} object, as returned by
\code{\link[=dbConnect]{dbConnect()}}.}

\item{x}{An \link{SQL} or \link{Id} object.}

\item{...}{Other arguments passed on to methods.}
}
\value{
\code{dbUnquoteIdentifier()} returns a list of objects
of the same length as the input.
For an empty vector, this function returns a length-0 object.
The names of the input argument are preserved in the output.
If \code{x} is a value returned by \code{dbUnquoteIdentifier()},
calling \code{dbUnquoteIdentifier(..., dbQuoteIdentifier(..., x))}
returns \code{list(x)}.
If \code{x} is an object of class \link[DBI:Id]{DBI::Id},
calling \code{dbUnquoteIdentifier(..., x)} returns \code{list(x)}.
(For backends it may be most convenient to return \link[DBI:Id]{DBI::Id} objects
to achieve this behavior, but this is not required.)

Plain character vectors can also be passed to \code{dbUnquoteIdentifier()}.
}
\description{
Call this method to convert a \link{SQL} object created by \code{\link[=dbQuoteIdentifier]{dbQuoteIdentifier()}}
back to a list of \link{Id} objects.

\Sexpr[results=rd,stage=render]{DBI:::methods_as_rd("dbUnquoteIdentifier")}
}
\section{Failure modes}{



An error is raised if a character vectors with a missing value is passed
as the \code{x} argument.

}

\section{Specification}{


For any character vector of length one, quoting (with \code{\link[DBI:dbQuoteIdentifier]{DBI::dbQuoteIdentifier()}})
then unquoting then quoting the first element is identical to just quoting.
This is also true for strings that
contain special characters such as a space,
a dot,
a comma,
or quotes used to mark strings
or identifiers,
if the database supports this.

Unquoting simple strings (consisting of only letters) wrapped with \code{\link[DBI:SQL]{DBI::SQL()}} and
then quoting via \code{\link[DBI:dbQuoteIdentifier]{DBI::dbQuoteIdentifier()}} gives the same result as just
quoting the string.
Similarly, unquoting expressions of the form \code{SQL("schema.table")}
and then quoting gives the same result as quoting the identifier
constructed by \code{Id("schema", "table")}.

}

\examples{
# Unquoting allows to understand the structure of a
# possibly complex quoted identifier
dbUnquoteIdentifier(
  ANSI(),
  SQL(c('"Catalog"."Schema"."Table"', '"Schema"."Table"', '"UnqualifiedTable"'))
)

# The returned object is always a list,
# also for Id objects
dbUnquoteIdentifier(ANSI(), Id("Catalog", "Schema", "Table"))

# Quoting and unquoting are inverses
dbQuoteIdentifier(
  ANSI(),
  dbUnquoteIdentifier(ANSI(), SQL("UnqualifiedTable"))[[1]]
)

dbQuoteIdentifier(
  ANSI(),
  dbUnquoteIdentifier(ANSI(), Id("Schema", "Table"))[[1]]
)
}
\seealso{
Other DBIConnection generics: 
\code{\link{DBIConnection-class}},
\code{\link{dbAppendTable}()},
\code{\link{dbAppendTableArrow}()},
\code{\link{dbCreateTable}()},
\code{\link{dbCreateTableArrow}()},
\code{\link{dbDataType}()},
\code{\link{dbDisconnect}()},
\code{\link{dbExecute}()},
\code{\link{dbExistsTable}()},
\code{\link{dbGetException}()},
\code{\link{dbGetInfo}()},
\code{\link{dbGetQuery}()},
\code{\link{dbGetQueryArrow}()},
\code{\link{dbIsReadOnly}()},
\code{\link{dbIsValid}()},
\code{\link{dbListFields}()},
\code{\link{dbListObjects}()},
\code{\link{dbListResults}()},
\code{\link{dbListTables}()},
\code{\link{dbQuoteIdentifier}()},
\code{\link{dbReadTable}()},
\code{\link{dbReadTableArrow}()},
\code{\link{dbRemoveTable}()},
\code{\link{dbSendQuery}()},
\code{\link{dbSendQueryArrow}()},
\code{\link{dbSendStatement}()},
\code{\link{dbWriteTable}()},
\code{\link{dbWriteTableArrow}()}
}
\concept{DBIConnection generics}
