server/expression library

SQL expression AST and evaluator (used by WHERE, HAVING, ON clauses).

Classes

BetweenExpr
BinaryExpr
BindParamExpr
A bind-parameter placeholder, e.g. ?, ?3, :name, @name, $x.
BindScope
One frame of bindings active during a prepared-statement execution.
CaseExpr
CASE WHEN ... THEN ... ELSE ... END. Both forms are supported: CASE WHEN <cond> THEN <v> ... [ELSE <v>] END (searched) CASE <subject> WHEN <v1> THEN <r1> ... [ELSE <v>] END (simple) The simple form is desugared by the parser into the searched form.
CastExpr
CAST(expr AS type).
ColumnExpr
ExistsExpr
EXISTS (SELECT ...) / NOT EXISTS (...).
Expr
FrameBound
FunctionCallExpr
Function call (scalar or aggregate). Evaluation of aggregate functions always throws here — the SELECT executor recognises and handles them out-of-band (per group).
InExpr
InSubqueryExpr
expr IN (SELECT ...) / NOT IN (SELECT ...).
LikeExpr
expr LIKE pattern ESCAPE escesc is an optional single-character escape used to literalise the next character of pattern (typically % or _).
LiteralExpr
ScalarSubqueryExpr
Scalar subquery (SELECT ...). The actual execution is delegated to a closure injected by the parser/executor (the parser doesn't depend on the database).
UnaryExpr
WindowFrame
WindowOrderItem
One ORDER BY item inside an OVER(...) clause. Mirrors the shape of statement-level OrderByItem but kept here to avoid a cyclic import.
WindowSpec
OVER(PARTITION BY ... ORDER BY ... frame) specification attached to a FunctionCallExpr to make it a window function. Either an inline spec or a name referencing a named window in the SELECT.

Enums

FrameBoundKind
Frame boundary kind.
FrameExclude
FrameMode
Window frame mode.

Constants

kAggregateFunctions → const Set<String>
kSqliteVersionString → const String
Reported by sqlite_version(). Mirrors a recent SQLite release we aim to be feature-compatible with.

Properties

connStateLookup int Function(String which)?
Per-connection state hook for last_insert_rowid(), changes() and total_changes(). The active Database.executeStmt installs this so the scalar functions can read connection-scoped counters without expression.dart depending on database.dart. Returns 0 when no connection context is active.
getter/setter pair
fts5CorpusLookup Fts5Index? Function(String table, String column)?
Hook installed by the engine: given a table and column name, return the corpus-aware FTS5 index, or null when no active database is in scope. Wired up by Database.executeStmt so that scalar functions can reach back into the database without expression.dart importing it (which would create a cycle).
getter/setter pair
kScalarFunctions Map<String, ScalarFn>
final

Functions

coerceForColumn(Object? value, ColumnDef col, {bool strict = false}) Object?
Coerce a value to the column's type for storage/comparison purposes.
evalPredicate(Expr e, Map<String, Object?> row) bool
Convenience: evaluate expression as boolean (NULL -> false).
jsonPathLookup(Object? root, String path) Object?
Resolve a SQLite-style JSON path (e.g. $, $.a.b, $[0], $.a[1].b) against root. Returns null if any segment is missing.
jsonPathRemove(Object? root, String path) Object?
Remove the value at path from root. Returns the (possibly mutated) root.
sqlCompare(Object a, Object b) int
sqlCompareNullable(Object? a, Object? b, {bool nullsFirst = true}) int
sqlEq(Object a, Object b) bool
sqlTruthy(Object? v) bool

Typedefs

ScalarFn = Object? Function(List<Object?> args)

Exceptions / Errors

RaiseException
Thrown by RAISE(action, message) inside a trigger. The trigger executor catches this and decides whether to silently ignore the current operation (IGNORE), abort it (ABORT/FAIL), or roll back the enclosing transaction (ROLLBACK).