typedColByName<T> method

T? typedColByName<T>(
  1. String columnName
)

Same as colByName but performs conversion of string data, into provided type T, if possible

Conversion is "typesafe", meaning that actual MySQL column type will be checked, to decide is it possible to make such a conversion

Throws MySQLClientException if conversion is not possible

Implementation

T? typedColByName<T>(String columnName) {
  final value = colByName(columnName);

  final colIndex = _colDefs.indexWhere(
    (element) => element.name.toLowerCase() == columnName.toLowerCase(),
  );

  final colDef = _colDefs[colIndex];

  return colDef.type
      .convertStringValueToProvidedType<T>(value, colDef.columnLength);
}