Call this method to convert a SQL object created by dbQuoteIdentifier()
back to a list of Id objects.
Arguments
- conn
A DBIConnection object, as returned by
dbConnect()
.- x
- ...
Other arguments passed on to methods.
Value
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 x
is a value returned by dbUnquoteIdentifier()
,
calling dbUnquoteIdentifier(..., dbQuoteIdentifier(..., x))
returns list(x)
.
If x
is an object of class Id,
calling dbUnquoteIdentifier(..., x)
returns list(x)
.
(For backends it may be most convenient to return Id objects
to achieve this behavior, but this is not required.)
Plain character vectors can also be passed to dbUnquoteIdentifier()
.
Failure modes
An error is raised if a character vectors with a missing value is passed
as the x
argument.
Specification
For any character vector of length one, quoting (with 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 SQL()
and
then quoting via dbQuoteIdentifier()
gives the same result as just
quoting the string.
Similarly, unquoting expressions of the form SQL("schema.table")
and then quoting gives the same result as quoting the identifier
constructed by Id("schema", "table")
.
See also
Other DBIConnection generics:
DBIConnection-class
,
dbAppendTable()
,
dbAppendTableArrow()
,
dbCreateTable()
,
dbCreateTableArrow()
,
dbDataType()
,
dbDisconnect()
,
dbExecute()
,
dbExistsTable()
,
dbGetException()
,
dbGetInfo()
,
dbGetQuery()
,
dbGetQueryArrow()
,
dbIsReadOnly()
,
dbIsValid()
,
dbListFields()
,
dbListObjects()
,
dbListResults()
,
dbListTables()
,
dbQuoteIdentifier()
,
dbReadTable()
,
dbReadTableArrow()
,
dbRemoveTable()
,
dbSendQuery()
,
dbSendQueryArrow()
,
dbSendStatement()
,
dbWriteTable()
,
dbWriteTableArrow()
Examples
# Unquoting allows to understand the structure of a
# possibly complex quoted identifier
dbUnquoteIdentifier(
ANSI(),
SQL(c('"Catalog"."Schema"."Table"', '"Schema"."Table"', '"UnqualifiedTable"'))
)
#> [[1]]
#> <Id> "Catalog"."Schema"."Table"
#>
#> [[2]]
#> <Id> "Schema"."Table"
#>
#> [[3]]
#> <Id> "UnqualifiedTable"
#>
# The returned object is always a list,
# also for Id objects
dbUnquoteIdentifier(ANSI(), Id("Catalog", "Schema", "Table"))
#> [[1]]
#> <Id> "Catalog"."Schema"."Table"
#>
# Quoting and unquoting are inverses
dbQuoteIdentifier(
ANSI(),
dbUnquoteIdentifier(ANSI(), SQL("UnqualifiedTable"))[[1]]
)
#> <SQL> "UnqualifiedTable"
dbQuoteIdentifier(
ANSI(),
dbUnquoteIdentifier(ANSI(), Id("Schema", "Table"))[[1]]
)
#> <SQL> "Schema"."Table"