SqlTranslator class

Walks an Expr tree and produces a SqlFragment.

The translator is stateless (no instance-level state). Each visit method builds a SqlFragment with its own bind list; the caller combines them. This makes the visitor safe to reuse and the bind-ordering explicit.

Implemented types

Constructors

SqlTranslator({String tableAlias = 'u', SqlDialect dialect = const DefaultDialect()})

Properties

dialect SqlDialect
The SQL dialect. Defaults to a SQLite dialect (the most common case). The Postgres engine passes a PostgresDialect; future engines pass their own.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tableAlias String
The alias for the table whose columns the lambda's body refers to. Default: 'u'. Must match the parameter name of the lambda being translated.
final

Methods

drainCollectedJoins() List<String>
.d: expose the collected JOIN clauses for the outer query to splice in. Returns a copy; the caller is free to modify the list.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
translate(Expr e) SqlFragment
Convenience for tests + callers: the visitor interface is Expr.accept<R>(ExprVisitor<R>). This is the same call, just spelled out.
translateLambda(Expr lambda) SqlFragment
Translates a top-level LambdaExpr predicate (the body of a where_ clause). Returns a SqlFragment suitable for use after a SQL WHERE keyword.
visitAggregate(AggregateExpr e) SqlFragment
override
visitBinary(BinaryExpr e) SqlFragment
override
visitCoalesce(CoalesceExpr e) SqlFragment
.e: a null-coalesce a ?? b.
override
visitConst(ConstExpr e) SqlFragment
override
visitGroupBy(GroupByExpr e) SqlFragment
override
visitHaving(HavingExpr e) SqlFragment
override
visitJoin(JoinExpr e) SqlFragment
override
visitLambda(LambdaExpr e) SqlFragment
override
visitList(ListExpr e) SqlFragment
override
visitMapLiteral(MapLiteralExpr e) SqlFragment
.e: a map literal {key1: val1, key2: val2}. The entries are stored as a flat list of MapEntry<Expr, Expr>.
override
visitMemberAccess(MemberAccessExpr e) SqlFragment
override
visitMethodCall(MethodCallExpr e) SqlFragment
override
visitNavRef(NavRef e) SqlFragment
.d: a navigation reference o.customer (returns the target column reference, e.g. c.name, and signals that a JOIN must be added).
override
visitNull(NullExpr e) SqlFragment
override
visitNullSafeAccess(NullSafeAccessExpr e) SqlFragment
.e: a null-safe member access a?.b (returns null if a is null).
override
visitParam(ParamExpr e) SqlFragment
override
visitTernary(TernaryExpr e) SqlFragment
.e: a ternary cond ? then: else.
override
visitUnary(UnaryExpr e) SqlFragment
override

Operators

operator ==(Object other) bool
The equality operator.
inherited