wrapWithOid wraps a Datum with a custom Oid.
(d Datum, oid oid.Oid)
| 3690 | |
| 3691 | // wrapWithOid wraps a Datum with a custom Oid. |
| 3692 | func wrapWithOid(d Datum, oid oid.Oid) Datum { |
| 3693 | switch v := d.(type) { |
| 3694 | case nil: |
| 3695 | return nil |
| 3696 | case *DInt: |
| 3697 | case *DString: |
| 3698 | case *DArray: |
| 3699 | case dNull, *DOidWrapper: |
| 3700 | panic(errors.AssertionFailedf("cannot wrap %T with an Oid", v)) |
| 3701 | default: |
| 3702 | // Currently only *DInt, *DString, *DArray are hooked up to work with |
| 3703 | // *DOidWrapper. To support another base Datum type, replace all type |
| 3704 | // assertions to that type with calls to functions like AsDInt and |
| 3705 | // MustBeDInt. |
| 3706 | panic(errors.AssertionFailedf("unsupported Datum type passed to wrapWithOid: %T", d)) |
| 3707 | } |
| 3708 | return &DOidWrapper{ |
| 3709 | Wrapped: d, |
| 3710 | Oid: oid, |
| 3711 | } |
| 3712 | } |
| 3713 | |
| 3714 | // UnwrapDatum returns the base Datum type for a provided datum, stripping |
| 3715 | // an *DOidWrapper if present. This is useful for cases like type switches, |
no outgoing calls
no test coverage detected
searching dependent graphs…