execute method

Future<SqlResult> execute(
  1. SqlCommand command, {
  2. ExecutionOptions options = const ExecutionOptions(),
  3. Iterable<String> changedTables = const [],
})

Executes bound SQL and returns raw rows and affected-row metadata.

changedTables explicitly reports writes for query invalidation; SQL text is never parsed to infer write targets. A transaction publishes these changes after commit and discards them after a confirmed rollback.

Implementation

Future<SqlResult> execute(
  SqlCommand command, {
  ExecutionOptions options = const ExecutionOptions(),
  Iterable<String> changedTables = const [],
}) {
  options.check();
  if (options.cancellation != null && !capabilities.cancellation) {
    throw const OrmException(
      'CAPABILITY.CANCEL',
      'This driver cannot cancel a running statement.',
    );
  }
  if (options.timeout != null && !capabilities.statementTimeout) {
    throw const OrmException(
      'CAPABILITY.CANCEL',
      'This driver does not support statement timeouts.',
    );
  }
  final tables = List<String>.unmodifiable(changedTables);
  return run((connection) async {
    final result = await executeOn(connection, command, options: options);
    _notifyChanged(tables);
    return result;
  }, acquire: options.acquisition);
}