decodeProtocolCell function

Object? decodeProtocolCell(
  1. Uint8List data,
  2. int odbcType
)

Converts binary cell data to a Dart value based on the protocol discriminant.

Implementation

Object? decodeProtocolCell(Uint8List data, int odbcType) {
  final type = OdbcType.fromDiscriminant(odbcType);
  if (type == OdbcType.binary) {
    return data;
  }
  if (type == OdbcType.integer) {
    if (data.length >= 4) {
      return ByteData.sublistView(data).getInt32(0, binaryProtocolLittleEndian);
    }
    return decodeProtocolText(data);
  }
  if (type == OdbcType.bigInt) {
    if (data.length >= 8) {
      return ByteData.sublistView(data).getInt64(0, binaryProtocolLittleEndian);
    }
    return decodeProtocolText(data);
  }
  return decodeProtocolText(data);
}