ENABLE-S-SQL-SYNTAX (&OPTIONAL (CHAR Q))
Enable a syntactic shortcut #Q(...) for (sql (...)). Optionally takes a character to use instead of #\Q.
Convert a string to something that might have been its original lisp name (does not work if this name contained non-alphanumeric characters other than #-)
SQL-ESCAPE-STRING (STRING &OPTIONAL PREFIX)
Escape string data so it can be used in a query.
Convert a symbol or string into a name that can be an sql table, column, or operation name. Add quotes when escape-p is true, or escape-p is :auto and the name contains reserved words.
SQL-ERROR (CONTROL &REST ARGS)
Return the type and whether it may be NULL.
Try to escape an expression at compile-time, if not possible, delay to runtime. Used to create stored procedures.
Helper for the select operator. Turns the part following :from into the proper SQL syntax for joining tables.
IMPLODE (SEP LIST)
Reduce a list of strings to a single string, inserting a separator between them.
MAKE-EXPANDER (ARITY NAME)
Generates an appropriate expander function for a given operator with a given arity.
Join adjacent strings in a list, leave other values intact.
SPLIT-ON-KEYWORDS% (SHAPE LIST)
Helper function for split-on-keywords. Extracts the values associated with the keywords from an argument list, and checks for errors.
Compile-time expansion of forms into lists of stuff that evaluates to strings (which will form an SQL query when concatenated).
SQL-EXPAND-LIST (ELTS &OPTIONAL (SEP , ))
Expand a list of elements, adding a separator in between them.
Concatenate a list of strings into a single one.
Turn a Lisp type expression into an SQL typename.
%BUILD-FOREIGN-REFERENCE (TARGET ON-DELETE ON-UPDATE)
EXPAND-CREATE-INDEX (NAME ARGS)
EXPAND-ROWS (ROWS LENGTH)
EXPAND-TABLE-COLUMN (COLUMN-NAME ARGS)
EXPAND-TABLE-CONSTRAINT (OPTION ARGS)
S-SQL-READER (STREAM CHAR MIN-ARGS)
SQL-EXPAND-NAMES (NAMES &OPTIONAL (SEP , ))
REGISTER-SQL-OPERATORS (ARITY &REST NAMES)
Define simple operators. Arity is one of :unary (like 'not'), :unary-postfix (the operator comes after the operand), :n-ary (like '+': the operator falls away when there is only one operand), :2+-ary (like '=', which is meaningless for one operand), or :n-or-unary (like '-', where the operator is kept in the unary case). After the arity follow any number of operators, either just a keyword, in which case the downcased symbol name is used as the operator, or a two-element list containing a keyword and a name string.
Compile form to an sql expression as far as possible.
DEF-SQL-OP (NAME ARGLIST &BODY BODY)
Macro to make defining syntax a bit more straightforward. Name should be the keyword identifying the operator, arglist a lambda list to apply to the arguments, and body something that produces a list of strings and forms that evaluate to strings.
SPLIT-ON-KEYWORDS (WORDS FORM &BODY BODY)
Used to handle arguments to some complex SQL operations. Arguments are divided by keywords, which are interned with the name of the non-keyword symbols in words, and bound to these symbols. After the naming symbols, a ? can be used to indicate this argument group is optional, an * to indicate it can consist of more than one element, and a - to indicate it does not take any elements.
DEF-DROP-OP (OP-NAME WORD)
Get the representation of a Lisp value so that it can be used in a query.
SQL-TYPE-NAME (LISP-TYPE &REST ARGS)
Transform a lisp type into a string containing something SQL understands. Default is to just use the type symbol's name.
EXPAND-SQL-OP (OP ARGS)
For overriding expansion of operators. Default is to just place operator name in front, arguments between parentheses behind it.
Setting this to T will make S-SQL add double quotes around identifiers in queries. Setting it :auto will turn on this behaviour only for reserved words.
Indicate whether S-SQL will use standard SQL strings (just use '' for #'), or backslash-style escaping. Setting this to NIL is always safe, but when the server is configured to allow standard strings (parameter 'standard_conforming_strings' is 'on'), the noise in queries can be reduced by setting this to T.
A set of all Postgres' reserved words, for automatic escaping.