SelectedQuery<R, F extends Fields, S extends Selection<R> > class
base
A selected result that retains both source fields and declared output fields.
Filters, joins, ordering, and grouping keep using F. A flat projection's
explicit asCte or set operation establishes its declared output scope. S
preserves that concrete selection type across query composition. Ordinary
result mappings and relation loading do not declare named SQL fields.
- Inheritance
- Implementers
- Available extensions
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 -
asCte(
String name) → DerivedQuery< R, O, Projection< R, O> > -
Available on SelectedQuery<
Exports named output slots into a fresh SQL scope.R, F, Projection< , provided by the ProjectedSql extensionR, O> > -
bind(
QueryContext context) → SelectedQuery< R, F, S> -
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) → SelectedQuery< R, F, S> - @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 -
distinct(
) → SelectedQuery< R, F, S> -
Removes duplicate SQL projections before any Dart mapping.
override
-
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)) → SelectedQuery<Object?> >R, F, S> -
Replaces SQL grouping expressions; selected non-aggregates must be grouped.
override
-
having(
Expr< bool?> condition(F)) → SelectedQuery<R, F, S> -
Adds an aggregate filter with AND to the existing HAVING clause.
override
-
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<
T, G extends Fields> (TableAlias< T, G> alias, {required Expr<bool?> on(F, G)}) → SelectedQuery<R, F, S> -
Adds an inner join using an independently created table alias.
override
-
leftJoin<
T, G extends Fields> (TableAlias< T, G> alias, {required Expr<bool?> on(F, G)}) → SelectedQuery<R, F, S> -
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)) → SelectedQuery<R, F, S> -
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) → SelectedQuery< R, F, S> -
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) → SelectedQuery< R, F, S> -
Replaces the row limit; count must be nonnegative.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
union<
G extends Fields> (SelectedQuery< R, G, Projection< other) → SelectedQuery<R, O> >R, O, Projection< R, O> > -
Available on SelectedQuery<
Combines rows from the same projection declaration, removing duplicates.R, F, Projection< , provided by the ProjectedSql extensionR, O> > -
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> (SelectedQuery< R, G, Projection< other) → SelectedQuery<R, O> >R, O, Projection< R, O> > -
Available on SelectedQuery<
Combines matching SQL rows, preserving duplicates.R, F, Projection< , provided by the ProjectedSql extensionR, O> > -
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 -
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)) → SelectedQuery<R, F, S> -
Adds a predicate with AND, preserving any existing filter.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited