Sql class final

A base helper class for composing SQL constructs.

This wrapper class and its descendants do not prevent the composition of invalid SQL; the goal is only to simplify the composition process by avoiding direct string concatenation and interpolation. For example, the following fragment composes a WHERE clause using SqlI, SqlL, and Sql.>=, and then passes the "(`distance` >= 43)" string to the SQLite.prepare function:

QueryId qid = sqlite.prepare(
  where: SqlI("distance") >= SqlL(43),
  /* ... */

The composition of SQL constructs using overloaded Dart operators follows Dart operator associativity and precedence. For example, & and | bind tighter than < and >.

See also: FtsQuery.

Implementers
Annotations
  • @immutable

Constructors

Sql.raw(String str)
Wraps the SQL construct provided in the given str argument.
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
str → String
The SQL construct wrapped by this Sql instance.
final

Methods

between(Sql a, Sql b) → Sql
Composes and returns a parenthesis-enclosed BETWEEN operator.
concat(Sql x) → Sql
Composes and returns a parenthesis-enclosed || operator.
equal(Sql x) → Sql
Composes and returns a parenthesis-enclosed == operator.
glob(Sql x) → Sql
Composes and returns a parenthesis-enclosed GLOB operator.
inX(Sql x) → Sql
Composes and returns a parenthesis-enclosed IN operator.
isEqual(Sql x) → Sql
Composes and returns a parenthesis-enclosed IS operator.
isNotEqual(Sql x) → Sql
Composes and returns a parenthesis-enclosed IS NOT operator.
like(Sql x) → Sql
Composes and returns a parenthesis-enclosed binary LIKE operator.
likeEscape(Sql a, Sql b) → Sql
Composes and returns a parenthesis-enclosed ternary LIKE operator.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
not() → Sql
Composes and returns a parenthesis-enclosed NOT operator.
notEqual(Sql x) → Sql
Composes and returns a parenthesis-enclosed != operator.
parens() → Sql
Encloses this SQL construct in parentheses and returns the result.
toString() → String
A string representation of this object.
inherited

Operators

operator %(Sql x) → Sql
Composes and returns a parenthesis-enclosed % operator.
operator &(Sql x) → Sql
Composes and returns a parenthesis-enclosed AND operator.
operator *(Sql x) → Sql
Composes and returns a parenthesis-enclosed * operator.
operator +(Sql x) → Sql
Composes and returns a parenthesis-enclosed + operator.
operator -(Sql x) → Sql
Composes and returns a parenthesis-enclosed binary - operator.
operator /(Sql x) → Sql
Composes and returns a parenthesis-enclosed / operator.
operator <(Sql x) → Sql
Composes and returns a parenthesis-enclosed < operator.
operator <=(Sql x) → Sql
Composes and returns a parenthesis-enclosed <= operator.
operator ==(Object other) → bool
The equality operator.
inherited
operator >(Sql x) → Sql
Composes and returns a parenthesis-enclosed > operator.
operator >=(Sql x) → Sql
Composes and returns a parenthesis-enclosed >= operator.
operator unary-() → Sql
Composes and returns a parenthesis-enclosed unary - operator.
operator |(Sql x) → Sql
Composes and returns a parenthesis-enclosed OR operator.