hasColumn method

bool hasColumn(
  1. String table,
  2. String column, {
  3. String? schema,
})

Returns true if a column exists within the captured snapshot.

Implementation

bool hasColumn(String table, String column, {String? schema}) {
  final snapshot = _requireSnapshot();
  final tableTarget = _applyTablePrefix(table, schema: schema).toLowerCase();
  final columnTarget = column.toLowerCase();
  final schemaTarget = schema?.toLowerCase();
  return snapshot.columns.any((entry) {
    final entrySchema = entry.schema?.toLowerCase();
    if (schemaTarget != null && entrySchema != schemaTarget) {
      return false;
    }
    if (entry.tableName?.toLowerCase() != tableTarget) {
      return false;
    }
    return entry.name.toLowerCase() == columnTarget;
  });
}