MssqlQuery class
An immutable SELECT. Every method returns a new instance, so a base query
can be shared between the page and its count without the two drifting.
- Implemented types
- Available extensions
- Annotations
-
- @immutable
Constructors
- MssqlQuery.from(String identifier, {String? as, MssqlSourceRef? ref})
-
Starts a query against
identifier, such asdbo.Orders.factory -
MssqlQuery.fromParts(List<
String> parts, {String? as, MssqlSourceRef? ref}) -
Starts a query against a source whose parts are already separated; see
MssqlSource.parts.
factory
- MssqlQuery.fromSource(MssqlSource source)
-
Starts a query against an already-built source.
factory
- MssqlQuery.fromSub(MssqlSelectQuery query, {required String as})
-
Starts a query from a derived table. SQL Server requires its alias.
factory
Properties
-
conditions
→ List<
MssqlCondition> -
final
-
ctes
→ List<
MssqlCte> -
The
WITHclause, in the order it is written.final - distinct → bool
-
final
-
grouping
→ List<
MssqlExpression> -
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- having → MssqlCondition?
-
final
-
joins
→ List<
MssqlJoin> -
final
- lockHint → String?
-
A table hint on the source, such as
WITH (UPDLOCK, ROWLOCK).final - maxRecursion → int?
-
OPTION (MAXRECURSION n). Null leaves SQL Server's default of 100, which stops a runaway recursion with an error rather than a hang.final - offset → int?
-
final
-
ordering
→ List<
MssqlOrder> -
final
-
projection
→ List<
MssqlExpression> -
final
- projectionCount → int?
-
Known number of selected expressions, or null when it cannot be proven.
no setteroverride
- rows → int?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- source → MssqlSource
-
final
- topRows → int?
-
SELECT TOP (n), which is not paging: no offset and no ordering needed.final
Methods
-
aggregateRows(
MssqlExpression aggregate) → MssqlQuery - An aggregate over the rows this query returns.
-
avg<
T> (MssqlSession session, String column, {MssqlDialect dialect = MssqlDialect.sql2012}) → Future< T?> -
Available on MssqlQuery, provided by the MssqlQueryExecution extension
AVGofcolumnover the rows this query returns, or null for none. -
chunk(
MssqlSession session, int size, Future< bool> handle(List<MssqlRow> rows), {MssqlDialect dialect = MssqlDialect.sql2012}) → Future<void> -
Available on MssqlQuery, provided by the MssqlQueryExecution extension
Walks the whole result in keyset pages ofsize, without holding it all in memory. -
compile(
{MssqlDialect dialect = MssqlDialect.sql2012}) → MssqlStatement -
Compiles to SQL and its bound values.
override
-
compileInto(
MssqlParameterAllocator parameters, MssqlDialect dialect, {bool nested = false}) → String -
override
-
count(
MssqlSession session, {MssqlDialect dialect = MssqlDialect.sql2012, Duration? timeout, MssqlCancellationToken? cancellationToken, MssqlQueryOptions options = MssqlQueryOptions.defaults}) → Future< int> -
Available on MssqlQuery, provided by the MssqlQueryExecution extension
How many rows this query returns. -
countDistinct(
Iterable< MssqlExpression> expressions) → MssqlQuery -
The number of distinct values of
expressionsamong the rows this query matches. -
countDistinctColumns(
MssqlSession session, Iterable< String> columns, {MssqlDialect dialect = MssqlDialect.sql2012, Duration? timeout}) → Future<int> -
Available on MssqlQuery, provided by the MssqlQueryExecution extension
How many distinct values ofcolumnsthe matched rows hold. -
countRows(
) → MssqlQuery -
SELECT COUNT_BIG(*)over the rows this query returns. -
crossJoin(
String identifier, {String? as}) → MssqlQuery -
doesntExist(
MssqlSession session, {MssqlDialect dialect = MssqlDialect.sql2012, Duration? timeout}) → Future< bool> -
Available on MssqlQuery, provided by the MssqlQueryExecution extension
-
exists(
MssqlSession session, {MssqlDialect dialect = MssqlDialect.sql2012, Duration? timeout}) → Future< bool> -
Available on MssqlQuery, provided by the MssqlQueryExecution extension
Whether the query matches anything. -
first(
MssqlSession session, {MssqlDialect dialect = MssqlDialect.sql2012, Duration? timeout, MssqlCancellationToken? cancellationToken, MssqlQueryOptions options = MssqlQueryOptions.defaults}) → Future< MssqlRow?> -
Available on MssqlQuery, provided by the MssqlQueryExecution extension
The first row, or null. -
firstOrFail(
MssqlSession session, {MssqlDialect dialect = MssqlDialect.sql2012, Duration? timeout}) → Future< MssqlRow> -
Available on MssqlQuery, provided by the MssqlQueryExecution extension
The first row, or StateError. -
fullJoin(
String identifier, {String? as, required MssqlCondition on}) → MssqlQuery -
get(
MssqlSession session, {MssqlDialect dialect = MssqlDialect.sql2012, Duration? timeout, MssqlCancellationToken? cancellationToken, MssqlQueryOptions options = MssqlQueryOptions.defaults}) → Future< List< MssqlRow> > -
Available on MssqlSelectQuery, provided by the MssqlSelectQueryExecution extension
Every row, as the driver's own typed rows. -
getAs<
T> (MssqlSession session, T map(MssqlRow row), {MssqlDialect dialect = MssqlDialect.sql2012, Duration? timeout}) → Future< List< T> > -
Available on MssqlSelectQuery, provided by the MssqlSelectQueryExecution extension
Every row, mapped bymap. -
groupBy(
Iterable< MssqlExpression> expressions) → MssqlQuery -
havingCondition(
MssqlCondition condition) → MssqlQuery -
innerJoin(
String identifier, {String? as, required MssqlCondition on}) → MssqlQuery -
join(
MssqlJoinKind kind, String identifier, {String? as, MssqlCondition? on}) → MssqlQuery -
joinSub(
MssqlJoinKind kind, MssqlSelectQuery query, {required String as, MssqlCondition? on}) → MssqlQuery -
lazy(
MssqlSession session, {int size = 500, MssqlDialect dialect = MssqlDialect.sql2012}) → Stream< MssqlRow> -
Available on MssqlQuery, provided by the MssqlQueryExecution extension
chunk as a stream, for a caller that would rather iterate than pass a callback. -
leftJoin(
String identifier, {String? as, required MssqlCondition on}) → MssqlQuery -
lockForUpdate(
) → MssqlQuery -
Locks the rows read against other readers that also intend to write:
WITH (UPDLOCK, ROWLOCK). -
max<
T> (MssqlSession session, String column, {MssqlDialect dialect = MssqlDialect.sql2012}) → Future< T?> -
Available on MssqlQuery, provided by the MssqlQueryExecution extension
-
min<
T> (MssqlSession session, String column, {MssqlDialect dialect = MssqlDialect.sql2012}) → Future< T?> -
Available on MssqlQuery, provided by the MssqlQueryExecution extension
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
orderBy(
Iterable< MssqlOrder> terms) → MssqlQuery -
paged(
{required int offset, required int rows}) → MssqlQuery -
Takes
rowsrows starting atoffset. -
pluck<
T> (MssqlSession session, String column, {MssqlDialect dialect = MssqlDialect.sql2012, Duration? timeout}) → Future< List< T?> > -
Available on MssqlQuery, provided by the MssqlQueryExecution extension
One column of every row. -
rightJoin(
String identifier, {String? as, required MssqlCondition on}) → MssqlQuery -
select(
Iterable< MssqlExpression> expressions) → MssqlQuery -
selectDistinct(
Iterable< MssqlExpression> expressions) → MssqlQuery -
Holds a shared lock on the rows read until the transaction ends:
WITH (HOLDLOCK, ROWLOCK). -
stream(
MssqlSession session, {MssqlDialect dialect = MssqlDialect.sql2012, Duration? timeout, MssqlCancellationToken? cancellationToken, MssqlQueryOptions options = MssqlQueryOptions.defaults}) → Stream< MssqlRow> -
Available on MssqlQuery, provided by the MssqlQueryExecution extension
Maps the native row stream without buffering the whole result. -
sum<
T> (MssqlSession session, String column, {MssqlDialect dialect = MssqlDialect.sql2012}) → Future< T?> -
Available on MssqlQuery, provided by the MssqlQueryExecution extension
SUMofcolumnover the rows this query returns, or null for none. -
top(
int rows) → MssqlQuery -
The first
rowsrows, with no offset:SELECT TOP (n). -
toString(
) → String -
A string representation of this object.
inherited
-
union(
MssqlSelectQuery other) → MssqlSetQuery -
override
-
unionAll(
MssqlSelectQuery other) → MssqlSetQuery -
override
-
unless(
bool condition, MssqlQuery build(MssqlQuery query), {MssqlQuery otherwise(MssqlQuery query)?}) → MssqlQuery - when, inverted.
-
value<
T> (MssqlSession session, String column, {MssqlDialect dialect = MssqlDialect.sql2012, Duration? timeout}) → Future< T?> -
Available on MssqlQuery, provided by the MssqlQueryExecution extension
One column of the first row. -
when(
bool condition, MssqlQuery build(MssqlQuery query), {MssqlQuery otherwise(MssqlQuery query)?}) → MssqlQuery -
Applies
buildonly whenconditionholds. -
whenNotNull<
T extends Object> (T? value, MssqlQuery build(MssqlQuery query, T value)) → MssqlQuery -
Applies
buildwhenvalueis not null, handing it to the callback already promoted to its non-nullable type. -
where(
MssqlCondition condition) → MssqlQuery -
Adds a condition. Repeated calls are combined with
AND. -
whereExists(
MssqlSelectQuery query) → MssqlQuery -
Available on MssqlQuery, provided by the MssqlSubqueryClauses extension
-
whereNotExists(
MssqlSelectQuery query) → MssqlQuery -
Available on MssqlQuery, provided by the MssqlSubqueryClauses extension
-
withCte(
String name, MssqlSelectQuery query, {List< String> columns = const <String>[]}) → MssqlQuery - Prefixes the query with a common table expression.
-
withExpression(
MssqlCte cte, {int? maxRecursion}) → MssqlQuery - Prefixes the query with an expression already built.
-
withHint(
String hint) → MssqlQuery - An arbitrary table hint, for the ones this does not name.
-
withRecursiveCte(
String name, {required MssqlSelectQuery anchor, required MssqlSelectQuery recursive, required List< String> columns, int? maxRecursion}) → MssqlQuery - Prefixes the query with a recursive expression.
-
withTypedCte(
MssqlTypedCte cte) → MssqlQuery -
Available on MssqlQuery, provided by the MssqlTypedCteClauses extension
Addscteto theWITHclause, carrying its recursion ceiling with it.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited