decodeTextColumnData decodes the given data using the given data type OID and returns the result as a golang value
(mi *pgtype.Map, data []byte, dataType uint32)
| 798 | |
| 799 | // decodeTextColumnData decodes the given data using the given data type OID and returns the result as a golang value |
| 800 | func decodeTextColumnData(mi *pgtype.Map, data []byte, dataType uint32) (interface{}, error) { |
| 801 | switch oid.Oid(dataType) { |
| 802 | case oid.T_date, oid.T_time, oid.T_timestamp, oid.T_timestamptz, oid.T__date, oid.T__time, oid.T__timestamp, oid.T__timestamptz: |
| 803 | // The codec converts time values into a format that breaks our assumptions later on, which is unnecessary as |
| 804 | // the server sends the correctly-formatted time anyway. |
| 805 | return string(data), nil |
| 806 | default: |
| 807 | if dt, ok := mi.TypeForOID(dataType); ok { |
| 808 | return dt.Codec.DecodeValue(mi, dataType, pgtype.TextFormatCode, data) |
| 809 | } |
| 810 | return string(data), nil |
| 811 | } |
| 812 | } |
| 813 | |
| 814 | // encodeColumnData encodes the given data using the given data type OID and returns the result as a string to be |
| 815 | // used in an INSERT or other DML query. |