Skip to content

Structure

SQLList

A fundamental syntactical expression - a list of subexpresions with a specified “separator” subexpression.
struct SQLList

Overview

When serialized, an empty SQLList outputs nothing, a single-item SQLList outputs the serialization of that one expression, and all other SQLLists output the entire list of subexpressions joined by an appropriate number of copies of the separator subexpression. The default separator is SQLRaw(", ").

Examples:

print(database.serialize(SQLList(SQLLiteral.string("a"), SQLLiteral.string("b"))).sql)
// "'a', 'b'"
print(database.serialize(SQLList(SQLLiteral.string("a"), SQLLiteral.string("b"), separator: SQLBinaryOperator.and)).sql)
// "'a'AND'b'"
print(database.serialize(SQLList(SQLLiteral.string("a"), SQLLiteral.string("b"), separator: SQLRaw(" AND ")).sql)
// "'a' AND 'b'"

Topics

Initializers

  • init(_:separator:)
    Create a list from a list of expressions and an optional separator expression.

Instance Properties

  • expressions
    The list of subexpressions to join.
  • separator
    The expression with which to join the list of subexpressions.

Instance Methods

  • serialize(to:)
    Invoked when a request is made to serialize the expression to raw SQL.

Relationships

Conforms To

See Also

Syntactic Expressions

  • SQLBinaryExpression
    A fundamental syntactical expression - a left and right operand joined by an infix operator.
  • SQLBinaryOperator
    SQL binary expression operators.
  • SQLBind
    A parameterizied value bound to the SQL query.
  • SQLFunction
    A call to a function available in SQL, expressed as a name and a (possibly empty) list of arguments.
  • SQLGroupExpression
    A fundamental syntactical expression - an arbitrary expression or list of expressions, surroudned by parenthesis.
  • SQLIdentifier
    A fundamental syntactical expression - a quoted identifier (also often referred to as a “name” or “object name”).
  • SQLLiteral
    A fundamental syntactical expression - one of several various kinds of literal SQL expressions.
  • SQLRaw
    A fundamental syntactical expression - an arbitrary string of raw SQL with no escaping or formating of any kind.