TableQuery<R, F extends Fields> class
A table-shaped SQL query with assignment-based update and delete. A selected/mapped result is a Query and cannot be used as a write target.
- Inheritance
- Implementers
- Available extensions
Constructors
-
TableQuery.internal(QueryContext database, F fields, QueryState state, Selection<
R> selection)
Properties
- database → QueryContext
-
The compilation or execution context that owns this query.
finalinherited
-
dependencies
→ ({bool opaque, Set<
TableSchema> tables}) -
Physical read dependencies used by subscriptions, including relation batches.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
asCte(
String name) → DerivedQuery< R, CteFields< F> , Selection<R> > -
Available on Query<
Names this SQL query for reuse. Constructing the CTE performs no I/O.R, F> , provided by the QueryCtes extension -
bind(
QueryContext context) → TableQuery< R, F> -
Rebind the root description to an execution context. Nested queries retain
their original context and are rejected when they do not match.
override
-
compile(
) → SqlCommand -
Validates and compiles SQL with separately bound parameters, without I/O.
inherited
-
copyQuery(
QueryState state) → TableQuery< R, F> - @nodoc
-
count(
{ExecutionOptions options = const ExecutionOptions()}) → Future< int> -
Counts the query's result rows, including its limit, offset and grouping.
inherited
-
cursorToken(
List< CursorTerm> cursor(F)) → String -
Available on Query<
Versioned, lossless cursor transport. This is pagination input, not an authorization token. The next query still applies its own WHERE policies.R, F> , provided by the KeysetQuery extension -
delete(
) → Mutation< F> - Prepares a delete; no SQL runs until the mutation is executed.
-
distinct(
) → Query< R, F> -
Removes duplicate SQL projections before any Dart mapping.
inherited
-
exists(
{ExecutionOptions options = const ExecutionOptions()}) → Future< bool> -
Checks whether the current query yields at least one row.
inherited
-
existsExpression(
) → Expr< bool> -
Builds a SQL EXISTS expression without executing a read.
inherited
-
first(
{ExecutionOptions options = const ExecutionOptions()}) → Future< R> -
Returns the first selected row, or throws
QUERY.CARDINALITYif empty.inherited -
firstOrNull(
{ExecutionOptions options = const ExecutionOptions()}) → Future< R?> -
Returns the first selected row, or null when the query is empty.
inherited
-
get(
{ExecutionOptions options = const ExecutionOptions()}) → Future< List< R> > -
Executes the query and decodes all selected rows.
inherited
-
groupBy(
List< Expr< group(F)) → Query<Object?> >R, F> -
Replaces SQL grouping expressions; selected non-aggregates must be grouped.
inherited
-
having(
Expr< bool?> condition(F)) → Query<R, F> -
Adds an aggregate filter with AND to the existing HAVING clause.
inherited
-
inspect(
) → QueryPlan -
Inspects SQL and conditional relation batches without acquiring a connection.
This does not ask the database optimizer for an execution plan.
inherited
-
join<
S, G extends Fields> (TableAlias< S, G> alias, {required Expr<bool?> on(F, G)}) → TableQuery<R, F> -
Adds an inner join using an independently created table alias.
override
-
leftJoin<
S, G extends Fields> (TableAlias< S, G> alias, {required Expr<bool?> on(F, G)}) → TableQuery<R, F> -
Adds a left join; use the alias's optional selection for absent rows.
override
-
map<
S> (S mapper(R)) → Query< S, F> -
Maps decoded rows in Dart. This does not create SQL columns or change
database DISTINCT/UNION semantics; compose SQL set operations first.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
orderBy(
List< OrderTerm> order(F)) → TableQuery<R, F> -
Replaces the query's ordering with the supplied expressions.
override
-
scalar(
) → Expr< R?> -
Converts a scalar selection into a nullable SQL subquery.
inherited
-
seekAfter(
List< CursorTerm> cursor(F)) → Query<R, F> -
Available on Query<
Adds a lexicographic boundary afterR, F> , provided by the KeysetQuery extensioncursorand replaces query ordering. -
seekToken(
String token, {required List< OrderTerm> orderBy(F)}) → Query<R, F> -
Available on Query<
Restores a cursorToken using the expected table and complete sort order.R, F> , provided by the KeysetQuery extension -
select<
S extends Selection< (T> , T>S selection(F)) → SelectedQuery< T, F, S> -
Available on Query<
Chooses selected SQL cells and the application result decoded from them.R, F> , provided by the SelectQuery extension -
single(
{ExecutionOptions options = const ExecutionOptions()}) → Future< R> -
Returns exactly one selected row or throws
QUERY.CARDINALITY.inherited -
singleOrNull(
{ExecutionOptions options = const ExecutionOptions()}) → Future< R?> -
Returns the only selected row, or null when empty.
inherited
-
skip(
int count) → TableQuery< R, F> -
Replaces the row offset; count must be nonnegative.
override
-
stream(
{int batchSize = 128, ExecutionOptions options = const ExecutionOptions()}) → Stream< R> -
Available on Query<
One database cursor, fetched on demand. Related rows are loaded per root batch on the same connection. Pause/await-for consumption provides demand.R, F> , provided by the QueryStreaming extension -
take(
int count) → TableQuery< R, F> -
Replaces the row limit; count must be nonnegative.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
union<
G extends Fields> (Query< R, G> other) → Query<R, UnionFields< F> > -
Available on Query<
Combines SQL scalars orR, F> , provided by the SetQueries extension.rowprojections. Both operands must use this database/session and the same codecs, column types and nullability. -
unionAll<
G extends Fields> (Query< R, G> other) → Query<R, UnionFields< F> > -
Available on Query<
Keeps duplicate SQL rows. Row order requires an explicit final orderBy.R, F> , provided by the SetQueries extension -
update(
List< Assignment> assignments(F)) → Mutation<F> - Prepares an update; call the mutation's execute or returning method.
-
watch(
{Iterable< TableSchema> reads = const [], ExecutionOptions options = const ExecutionOptions()}) → Stream<List< R> > -
Available on Query<
Initial snapshot followed by fresh snapshots after relevant committed writes. Add tables hidden inside raw SQL withR, F> , provided by the WatchQuery extensionreads. Read errors are emitted without closing the stream, allowing a later invalidation to retry the query. -
where(
Expr< bool?> condition(F)) → TableQuery<R, F> -
Adds a predicate with AND, preserving any existing filter.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited