MCPcopy Index your code
hub / github.com/aarondl/sqlboiler / encode

Function encode

types/array.go:55–83  ·  view source on GitHub ↗
(parameterStatus *parameterStatus, x any, pgtypOid oid.Oid)

Source from the content-addressed store, hash-verified

53}
54
55func 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.

Callers 1

appendValueFunction · 0.85

Calls 3

encodeByteaFunction · 0.85
formatTsFunction · 0.85
errorfFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…