columnType method
Returns the column type for the requested table/column if available.
Implementation
String? columnType(String table, String column, {String? schema}) {
final snapshot = _requireSnapshot();
final tableTarget = _applyTablePrefix(table, schema: schema).toLowerCase();
final columnTarget = column.toLowerCase();
final schemaTarget = schema?.toLowerCase();
final match = snapshot.columns.firstWhere((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;
}, orElse: () => const SchemaColumn(name: '', dataType: ''));
return match.name.isEmpty ? null : match.dataType;
}