spec_sql_quote_literal
Value
dbQuoteLiteral()
returns an object that can be coerced to character,
of the same length as the input.
For an empty
integer,
numeric,
character,
logical,
date,
time,
or blob vector,
this function returns a length-0 object.
When passing the returned object again to dbQuoteLiteral()
as x
argument, it is returned unchanged.
Passing objects of class DBI::SQL should also return them unchanged.
(For backends it may be most convenient to return DBI::SQL objects
to achieve this behavior, but this is not required.)
Specification
The returned expression can be used in a SELECT ...
query,
and the value of
dbGetQuery(paste0("SELECT ", dbQuoteLiteral(x)))[[1]]
must be equal to x
for any scalar
integer,
numeric,
string,
and logical.
If x
is NA
, the result must merely satisfy is.na()
.
The literals "NA"
or "NULL"
are not treated specially.
NA
should be translated to an unquoted SQL NULL
,
so that the query SELECT * FROM (SELECT 1) a WHERE ... IS NULL
returns one row.
See also
Other sql specifications:
spec_sql_append_table
,
spec_sql_create_table
,
spec_sql_exists_table
,
spec_sql_list_fields
,
spec_sql_list_objects
,
spec_sql_list_tables
,
spec_sql_quote_identifier
,
spec_sql_quote_string
,
spec_sql_read_table
,
spec_sql_remove_table
,
spec_sql_unquote_identifier
,
spec_sql_write_table