sqlAssertions: SQL Assertions and Formats

sqlAssertPatternR Documentation

SQL Assertions and Formats

Description

These functions can be used to format and check the input of queries.

Usage

sqlAssertPattern(x, pattern, negate = TRUE)

sqlAssertChar(x)

sqlAssertChars(x)

sqlAssertNum(x)

sqlAssertNums(x)

sqlAssertAlnum(x)

sqlAssertAlnums(x)

sqlParan(x, assert = identity)

sqlComma(x, assert = identity)

sqlEsc(x, assert = identity, with = "`")

sqlName(x)

sqlNames(x)

sqlInNums(x)

sqlInChars(x)

sqlInAlnums(x)

Arguments

x

(ANY) input

pattern

(character) a regular expression used in grepl

negate

(logical) if TRUE then an error is thrown if at least one of the elements in x match pattern. If FALSE all elements in x must match the pattern.

assert

(function) an assertion function

with

(character)

Examples

# Will format and check:
sqlInChars(letters[1:2])
sqlInNums(1:2)
sqlNames(letters[1:2])
sqlName("a")

# Only check:
sqlAssertNum(1)
sqlAssertNums(1:2)
sqlAssertChar("a")
sqlAssertChars(letters[1:2])

INWT/dbtools documentation built on Oct. 9, 2024, 3:53 p.m.