Sql class sealed
Immutable SQL text, values and composition, with no connection or row cache.
Text is trusted SQL. Supply application values through named parameters; placeholders cannot stand for identifiers or SQL syntax. Native SQL is not translated between engines. Compilation checks lexical boundaries and one statement, while the database checks SQL semantics.
Constructors
-
Sql(String text, {Map<
String, Object?> parameters = const {}}) -
Captures text and exactly its
:nameparameters. Repeated local names share a value. Use SqlValue for domain types and explicit storage codecs. Raw scalar values retain the driver's type inference; maps/lists require a codec. Byte buffers and the parameter map are copied at construction. In PostgreSQL, escape a literal colon as\:outside quotes/comments when followed by a name, for exampler'items[1\:array_length(items, 1)]'.factory -
Sql.dialects(Map<
SqlDialect, Sql> variants) -
Selects exactly the current dialect; missing branches fail before execution.
factory
- Sql.identifier(String name)
-
Quotes one identifier, including any literal dots in its name.
factory
-
Sql.parts(Iterable<
Object> parts) -
Joins trusted text and Sql fragments at complete lexical boundaries.
A newline separates parts so comments and tokens cannot span boundaries.
Each nested fragment owns its parameter names; matching names never collide.
factory
- Sql.table(TableSchema table)
-
Quotes physical table and namespace separately. Namespaces require PostgreSQL.
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
compile(
Capabilities capabilities) → SqlCommand - Compiles once for the current capabilities without acquiring a connection. Accepts one trailing semicolon. Parameter limits use actual protocol slots.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
returns<
R> (ResultShape< R> result) → SqlQuery<R> - Attaches an optional result contract; no SQL is rewritten or executed.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited