Skip to content

Structure

SQLBinaryExpression

A fundamental syntactical expression - a left and right operand joined by an infix operator.
struct SQLBinaryExpression

Overview

This construct forms the basis of most comparisons, conditionals, and compounds which can be represented by an expression.

For example, the expression foo = 1 AND bar <> 'baz' OR bop - 5 NOT IN (1, 3) can be represented in terms of nested SQLBinaryExpressions (note that there is more than one “correct” way to nest this particular example):

let expr = SQLBinaryExpression(
    SQLBinaryExpression(SQLColumn("foo"), .equal, SQLLiteral.numeric("1")),
    .and,
    SQLBinaryExpression(
        SQLBinaryExpression(SQLColumn("bar"), .notEqual, SQLLiteral.string("baz")),
        .or,
        SQLBinaryExpression(
            SQLBinaryExpression(SQLColumn("bop"), .subtract, SQLLiteral.numeric("5")),
            .notIn,
            SQLGroupExpression(SQLLiteral.numeric("1"), SQLLiteral.numeric("3"))
        )
    )
)

Topics

Initializers

Instance Properties

  • left
    The left-side operand of the expression.
  • op
    The operator joining the left and right operands.
  • right
    The right-side operand of the expression.

Instance Methods

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

Relationships

Conforms To

See Also

Syntactic Expressions

  • 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”).
  • SQLList
    A fundamental syntactical expression - a list of subexpresions with a specified “separator” subexpression.
  • 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.