trashed method

Future<bool> trashed(
  1. TKey key
)

Whether the row exists and carries the configured deleted value.

Implementation

Future<bool> trashed(TKey key) async {
  _requireKey('trashed');
  final soft = binding.softDelete;
  if (soft == null) return false;
  var query = MssqlQuery.fromParts(binding.nameParts, ref: binding.sourceRef)
      .select(<MssqlExpression>[const MssqlProbeLiteral()])
      .where(_keyCondition(key))
      .where(soft.deleted)
      .top(1);
  for (final condition in _globalScopeConditions) {
    query = query.where(condition);
  }
  final statement = query.compile(dialect: await _dialect());
  final rows = await session.queryTypedRows(
    statement.sql,
    parameters: statement.parameters,
    options: options,
    timeout: options.timeout,
    cancellationToken: options.cancellationToken,
    // A SELECT this class compiled from its own AST is safe to repeat, so
    // a dropped connection is recovered by the driver instead of
    // surfacing here. A user predicate carrying `raw(...)` takes the
    // classification back to never — see MssqlStatementRetry.
    retry: statement.readRetry,
  );
  return rows.isNotEmpty;
}