sql

0th

Percentile

SQL escaping.

These functions are critical when writing functions that translate R functions to sql functions. Typically a conversion function should escape all it's inputs and return an sql object.

Keywords
internal
Usage
sql(...)

ident(...)

is.sql(x)

is.ident(x)

escape(x, parens = NA, collapse = " ", con = NULL)

sql_vector(x, parens = NA, collapse = " ", con = NULL)

Arguments
...

Character vectors that will be combined into a single SQL expression. ident flags its input as a identifier, to ensure that it gets the correct quoting.

x

An object to escape. Existing sql vectors will be left as is, character vectors are escaped with single quotes, numeric vectors have trailing .0 added if they're whole numbers, identifiers are escaped with double quotes.

parens, collapse

Controls behaviour when multiple values are supplied. parens should be a logical flag, or if NA, will wrap in parens if length > 1.

Default behaviour: lists are always wrapped in parens and separated by commas, identifiers are separated by commas and never wrapped, atomic vectors are separated by spaces and wrapped in parens if needed.

Aliases
  • escape
  • ident
  • is.ident
  • is.sql
  • sql
  • sql_vector
Examples
library(dplyr) # Doubles vs. integers escape(1:5) escape(c(1, 5.4)) # String vs known sql vs. sql identifier escape("X") escape(sql("X")) escape(ident("X")) # Escaping is idempotent escape("X") escape(escape("X")) escape(escape(escape("X")))
Documentation reproduced from package dplyr, version 0.5.0, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.