hasColumns method

  1. @override
Future<bool> hasColumns(
  1. String table,
  2. List<String> columns, {
  3. String? schema,
})
override

Determines if the given table has all of the specified columns.

Implementation

@override
Future<bool> hasColumns(
  String table,
  List<String> columns, {
  String? schema,
}) async {
  final tableColumns = await listColumns(table, schema: schema);
  final lowerCaseColumns = tableColumns
      .map((c) => c.name.toLowerCase())
      .toSet();

  for (final column in columns) {
    if (!lowerCaseColumns.contains(column.toLowerCase())) {
      return false;
    }
  }

  return true;
}