(parameterStatus *parameterStatus, x any, pgtypOid oid.Oid)
| 53 | } |
| 54 | |
| 55 | func encode(parameterStatus *parameterStatus, x any, pgtypOid oid.Oid) []byte { |
| 56 | switch v := x.(type) { |
| 57 | case int64: |
| 58 | return strconv.AppendInt(nil, v, 10) |
| 59 | case float64: |
| 60 | return strconv.AppendFloat(nil, v, 'f', -1, 64) |
| 61 | case []byte: |
| 62 | if pgtypOid == oid.T_bytea { |
| 63 | return encodeBytea(parameterStatus.serverVersion, v) |
| 64 | } |
| 65 | |
| 66 | return v |
| 67 | case string: |
| 68 | if pgtypOid == oid.T_bytea { |
| 69 | return encodeBytea(parameterStatus.serverVersion, []byte(v)) |
| 70 | } |
| 71 | |
| 72 | return []byte(v) |
| 73 | case bool: |
| 74 | return strconv.AppendBool(nil, v) |
| 75 | case time.Time: |
| 76 | return formatTs(v) |
| 77 | |
| 78 | default: |
| 79 | errorf("encode: unknown type for %T", v) |
| 80 | } |
| 81 | |
| 82 | panic("not reached") |
| 83 | } |
| 84 | |
| 85 | // Parse a bytea value received from the server. Both "hex" and the legacy |
| 86 | // "escape" format are supported. |
no test coverage detected
searching dependent graphs…