Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupportedType = errors.New("unsupported type")
Functions ¶
This section is empty.
Types ¶
type Map ¶
func (*Map[T]) UnmarshalJSON ¶
type Null ¶
type Null[T any] struct { sql.Null[T] // ParsedNull is a helper field to distinguish between a null value and an omitted field during JSON unmarshalling. // - if the field is present in the JSON (even if it's null), ParsedNull will be true. ParsedNull bool `json:"-"` }
func NewNullFromPtr ¶
NewNullFromPtr creates a Null[T] from a pointer to T.
- If the pointer is nil, it returns a Null[T] with Valid set to false and V set to the zero value of T.
func NewNullWithValid ¶
NewNullWithValid creates a Null[T] with the given value and Valid set to the specified boolean.
func (Null[T]) MarshalJSON ¶
func (*Null[T]) Merge ¶
Merge merges the current Null[T] with an old one, preserving the old value if the current one is not valid and not explicitly set to null.
This relies on types.Null's ParsedNull marker, which captures what a plain Go zero value cannot: whether the client said "leave this alone" or "make this empty".
func (*Null[T]) Present ¶
Present reports whether the field was in the update JSON at all, with either a value or an explicit null. Use it when a merge is not a straight replacement — a secret that is kept unless explicitly cleared, say.
func (Null[T]) Ptr ¶
func (n Null[T]) Ptr() *T
Ptr returns a pointer to the inner value if Valid is true, otherwise it returns nil.
func (*Null[T]) UnmarshalJSON ¶
func (Null[T]) ValueOrZero ¶
func (n Null[T]) ValueOrZero() T
ValueOrZero returns the inner value if valid, otherwise zero.
type NullDecimal ¶
type NullDecimal = decimal.NullDecimal
type RawJSON ¶
type RawJSON []byte
RawJSON same functionality with json.RawMessage and scan and value methods.
func (RawJSON) MarshalJSON ¶
MarshalJSON returns m as the JSON encoding of m.
func (*RawJSON) UnmarshalJSON ¶
UnmarshalJSON sets *m to a copy of data.