decodeValue method
dynamic
decodeValue(
- String value,
- int pgType, {
- String? connectionName,
})
Implementation
decodeValue(String value, int pgType, {String? connectionName}) {
switch (pgType) {
case _BOOL:
return value == 't';
case _INT2: // smallint
case _INT4: // integer
case _INT8: // bigint
return int.parse(value);
case _FLOAT4: // real
case _FLOAT8: // double precision
case _NUMERIC: //Work only for smaller precision
return double.parse(value);
case _TIMESTAMP:
case _TIMESTAMPZ:
case _DATE:
return decodeDateTime(value, pgType, connectionName: connectionName);
case _JSON:
case _JSONB:
return jsonDecode(value);
//Not supported it yet -- backward compatibility issue, such as
//unable to jsonize and compare...
//case _TID:
// assert(value.startsWith('(') && value.endsWith(')'));
// value = value.substring(1, value.length - 1);
// final i = value.indexOf(',');
// return (int.parse(value.substring(0, i)), int.parse(value.substring(i + 1)));
//TODO binary bytea
// Not implemented yet - return a string.
//case _MONEY:
//case _TIMETZ:
//case _TIME:
//case _INTERVAL:
default:
final scalarType = _arrayTypes[pgType];
if (scalarType != null)
return decodeArray(value, scalarType, connectionName: connectionName);
// Return a string for unknown types. The end user can parse this.
return value;
}
}