safe_arg: Extract an argument from a list ensuring SQL-safety

Description Usage Arguments Value Author(s)

Description

If the list contains an item of the given name, the return value will be that item coerced to the given type. For character strings, single quotes will be doubled so that the object is safe for use in SQL queries, provided that strings are enclosed in single quotes in the query.

Usage

1
safe_arg(x, name, type, scalar = TRUE, nullValue = NULL)

Arguments

x

list object with names

name

unquoted object name

type

unquoted type name, one of "character", "integer", "logical", "numeric", "list" or abbreviation thereof.

scalar

if TRUE (the default) return a vector of length 1, dropping any additional items. Otherwise, return a vector with the same length as the item from x. If type=="list", the vector is of mode "list".

nullValue

if the item is not present, return this value. default: NULL

Value

If there is no item with the given name in x, then return nullValue.

Author(s)

John Brzustowski jbrzusto@REMOVE_THIS_PART_fastmail.fm


jbrzusto/motus-R-package documentation built on May 18, 2019, 7:03 p.m.