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
init(any SQLExpression, SQLBinaryOperator, any SQLExpression)Create anSQLBinaryExpressionfrom two operand expressions and a predefined binary operator.init(left: any SQLExpression, op: any SQLExpression, right: any SQLExpression)Create anSQLBinaryExpressionfrom component expressions.
Instance Properties
let left: any SQLExpressionThe left-side operand of the expression.let op: any SQLExpressionThe operator joining the left and right operands.let right: any SQLExpressionThe right-side operand of the expression.
Instance Methods
func serialize(to: inout SQLSerializer)Invoked when a request is made to serialize the expression to raw SQL.
Relationships
Conforms To
SQLExpressionSwift.SendableSwift.SendableMetatype
See Also
Syntactic Expressions
enum SQLBinaryOperatorSQL binary expression operators.struct SQLBindA parameterizied value bound to the SQL query.struct SQLFunctionA call to a function available in SQL, expressed as a name and a (possibly empty) list of arguments.struct SQLGroupExpressionA fundamental syntactical expression - an arbitrary expression or list of expressions, surroudned by parenthesis.struct SQLIdentifierA fundamental syntactical expression - a quoted identifier (also often referred to as a “name” or “object name”).struct SQLListA fundamental syntactical expression - a list of subexpresions with a specified “separator” subexpression.enum SQLLiteralA fundamental syntactical expression - one of several various kinds of literal SQL expressions.struct SQLRawA fundamental syntactical expression - an arbitrary string of raw SQL with no escaping or formating of any kind.