wrapWithOid wraps a Datum with a custom Oid.
(d Datum, oid oid.Oid)
| 2022 | |
| 2023 | // wrapWithOid wraps a Datum with a custom Oid. |
| 2024 | func wrapWithOid(d Datum, oid oid.Oid) Datum { |
| 2025 | switch v := d.(type) { |
| 2026 | case nil: |
| 2027 | return nil |
| 2028 | case *DInt: |
| 2029 | case *DString: |
| 2030 | case *DArray: |
| 2031 | case NullLiteral, *DOidWrapper: |
| 2032 | panic(errors.AssertionFailedf("cannot wrap %T with an Oid", v)) |
| 2033 | default: |
| 2034 | // Currently only *DInt, *DString, *DArray are hooked up to work with |
| 2035 | // *DOidWrapper. To support another base Datum type, replace all type |
| 2036 | // assertions to that type with calls to functions like AsDInt and |
| 2037 | // MustBeDInt. |
| 2038 | panic(errors.AssertionFailedf("unsupported Datum type passed to wrapWithOid: %T", d)) |
| 2039 | } |
| 2040 | return &DOidWrapper{ |
| 2041 | Wrapped: d, |
| 2042 | Oid: oid, |
| 2043 | } |
| 2044 | } |
| 2045 | |
| 2046 | // UnwrapDatum returns the base Datum type for a provided datum, stripping |
| 2047 | // an *DOidWrapper if present. This is useful for cases like type switches, |
no outgoing calls
no test coverage detected