getAll method

  1. @override
Future<List<Map<String, dynamic>>> getAll(
  1. String sql, [
  2. List? arguments
])
override

Logs the query and returns pre-configured data if sql contains a key defined in _smartResponses; otherwise returns _defaultData.

Implementation

@override
Future<List<Map<String, dynamic>>> getAll(
  String sql, [
  List<dynamic>? arguments,
]) async {
  lastSql = sql;
  lastArgs = arguments;
  history.add(sql);

  if (_inTransaction) {
    transactionHistory.add(sql);
  }

  // Simple substring matching to find the correct mock response.
  // Check raw SQL first
  for (var key in _smartResponses.keys) {
    if (sql.contains(key)) {
      return _smartResponses[key]!;
    }
  }

  // Check normalized (unquoted) SQL for backward compatibility with tests
  final normalized = _normalize(sql);
  for (var key in _smartResponses.keys) {
    if (normalized.contains(key)) {
      return _smartResponses[key]!;
    }
  }

  return _defaultData;
}