applyRange static method

SqlStatement applyRange(
  1. SqlStatement statement,
  2. int from,
  3. int to
)

Adds LIMIT and OFFSET clauses (for range) to a SqlStatement. Replaces existing.

Implementation

static SqlStatement applyRange(SqlStatement statement, int from, int to) {
  if (statement.operationType != SqlOperationType.select) {
    print("Warning: Applying range to non-SELECT statement.");
  }
  if (from < 0 || to < from) {
    throw ArgumentError('Invalid range: from=$from, to=$to');
  }
  final count = to - from + 1;
  return statement.copyWith(limit: count, offset: from);
}