Documentation
¶
Index ¶
- Variables
- type Bool
- func (b Bool) Equal(other Bool) bool
- func (b Bool) IsZero() bool
- func (b Bool) MarshalJSON() ([]byte, error)
- func (b Bool) MarshalText() ([]byte, error)
- func (b Bool) Ptr() *bool
- func (b *Bool) SetValid(v bool)
- func (b *Bool) UnmarshalJSON(data []byte) error
- func (b *Bool) UnmarshalText(text []byte) error
- func (b Bool) Value() (driver.Value, error)
- func (b Bool) ValueOr(v bool) bool
- func (b Bool) ValueOrZero() bool
- type Byte
- type Date
- func (d Date) Equal(other Date) bool
- func (d Date) ExactEqual(other Date) bool
- func (d Date) IsZero() bool
- func (d Date) MarshalJSON() ([]byte, error)
- func (d Date) MarshalText() ([]byte, error)
- func (d Date) Ptr() *datetime.Date
- func (d *Date) SetValid(v datetime.Date)
- func (d *Date) UnmarshalJSON(data []byte) error
- func (d *Date) UnmarshalText(text []byte) error
- func (d Date) ValueOr(v datetime.Date) datetime.Date
- func (d Date) ValueOrZero() datetime.Date
- type DateTime
- func (dt DateTime) Equal(other DateTime) bool
- func (dt DateTime) ExactEqual(other DateTime) bool
- func (dt DateTime) IsZero() bool
- func (dt DateTime) MarshalJSON() ([]byte, error)
- func (dt DateTime) MarshalText() ([]byte, error)
- func (dt DateTime) Ptr() *datetime.DateTime
- func (dt *DateTime) SetValid(v datetime.DateTime)
- func (dt *DateTime) UnmarshalJSON(data []byte) error
- func (dt *DateTime) UnmarshalText(text []byte) error
- func (dt DateTime) ValueOr(v datetime.DateTime) datetime.DateTime
- func (dt DateTime) ValueOrZero() datetime.DateTime
- type Decimal
- func (d Decimal) Equal(other Decimal) bool
- func (d Decimal) ExactEqual(other Decimal) bool
- func (d Decimal) IsZero() bool
- func (d Decimal) Ptr() *decimal.Decimal
- func (d *Decimal) SetValid(v decimal.Decimal)
- func (d Decimal) ValueOr(v decimal.Decimal) decimal.Decimal
- func (d Decimal) ValueOrZero() decimal.Decimal
- type Float
- type Int
- type Int16
- type Int32
- type String
- type Time
- func (t Time) Equal(other Time) bool
- func (t Time) ExactEqual(other Time) bool
- func (t Time) IsZero() bool
- func (t Time) MarshalJSON() ([]byte, error)
- func (t Time) MarshalText() ([]byte, error)
- func (t Time) Ptr() *datetime.Time
- func (t *Time) SetValid(v datetime.Time)
- func (t *Time) UnmarshalJSON(data []byte) error
- func (t *Time) UnmarshalText(text []byte) error
- func (t Time) ValueOr(v datetime.Time) datetime.Time
- func (t Time) ValueOrZero() datetime.Time
- type Value
Constants ¶
This section is empty.
Variables ¶
var ( StringFrom = null.StringFrom StringFromPtr = null.StringFromPtr NewString = null.NewString IntFrom = null.IntFrom IntFromPtr = null.IntFromPtr NewInt = null.NewInt Int16From = null.Int16From Int16FromPtr = null.Int16FromPtr NewInt16 = null.NewInt16 Int32From = null.Int32From Int32FromPtr = null.Int32FromPtr NewInt32 = null.NewInt32 FloatFrom = null.FloatFrom FloatFromPtr = null.FloatFromPtr NewFloat = null.NewFloat ByteFrom = null.ByteFrom ByteFromPtr = null.ByteFromPtr NewByte = null.NewByte )
var ErrInvalidBoolText = errors.New("null: invalid input for UnmarshalText")
ErrInvalidBoolText indicates invalid text for null.Bool UnmarshalText.
Functions ¶
This section is empty.
Types ¶
type Bool ¶
Bool is a nullable bool. It does not consider false values to be null. It will decode to null, not false, if null.
func BoolFromPtr ¶
BoolFromPtr creates a new Bool that will be null if f is nil.
func (Bool) IsZero ¶
IsZero returns true for invalid Bools, for future omitempty support (Go 1.4?) A non-null Bool with a 0 value will not be considered zero.
func (Bool) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this Bool is null.
func (Bool) MarshalText ¶
MarshalText implements encoding.TextMarshaler. It will encode a blank string if this Bool is null.
func (Bool) Ptr ¶
Ptr returns a pointer to this Bool's value, or a nil pointer if this Bool is null.
func (*Bool) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will not be considered a null Bool.
func (*Bool) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Bool if the input is blank. It will return an error if the input is not an integer, blank, or "null".
func (Bool) Value ¶
Value implements driver.Valuer. It returns nil if this Bool is null, otherwise 1 or 0.
func (Bool) ValueOrZero ¶
ValueOrZero returns the inner value if valid, otherwise false.
type Date ¶
Date is a nullable datetime.Date. It supports SQL and JSON serialization. It will marshal to null if null.
func DateFromPtr ¶
DateFromPtr creates a new Date that will be null if d is nil.
func (Date) Equal ¶
Equal returns true if both Date objects encode the same date or are both null. Two dates can be equal even if they are in different locations. For example, 2023-01-01 +0200 CEST and 2023-01-01 UTC are Equal.
func (Date) ExactEqual ¶
ExactEqual returns true if both Date objects are equal or both null. ExactEqual returns false for dates that are in different locations or have a different monotonic clock reading.
func (Date) IsZero ¶
IsZero returns true for invalid Dates, hopefully for future omitempty support. A non-null Date with a zero value will not be considered zero.
func (Date) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this date is null.
func (Date) MarshalText ¶
MarshalText implements encoding.TextMarshaler. It returns an empty string if invalid, otherwise datetime.Date's MarshalText.
func (Date) Ptr ¶
Ptr returns a pointer to this Date's value, or a nil pointer if this Date is null.
func (*Date) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports string and null input.
func (*Date) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler. It has backwards compatibility with v3 in that the string "null" is considered equivalent to an empty string and unmarshaling will succeed. This may be removed in a future version.
func (Date) ValueOrZero ¶
ValueOrZero returns the inner value if valid, otherwise zero.
type DateTime ¶
DateTime is a nullable datetime.DateTime. It supports SQL and JSON serialization. It will marshal to null if null.
func DateTimeFrom ¶
DateTimeFrom creates a new DateTime that will always be valid.
func DateTimeFromPtr ¶
DateTimeFromPtr creates a new DateTime that will be null if dt is nil.
func NewDateTime ¶
NewDateTime creates a new DateTime.
func (DateTime) Equal ¶
Equal returns true if both DateTime objects encode the same datetime or are both null. Two datetimes can be equal even if they are in different locations. For example, 2023-01-01 12:00:00 +0200 CEST and 2023-01-01 10:00:00 UTC are Equal.
func (DateTime) ExactEqual ¶
ExactEqual returns true if both DateTime objects are equal or both null. ExactEqual returns false for datetimes that are in different locations or have a different monotonic clock reading.
func (DateTime) IsZero ¶
IsZero returns true for invalid DateTimes, hopefully for future omitempty support. A non-null DateTime with a zero value will not be considered zero.
func (DateTime) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this datetime is null.
func (DateTime) MarshalText ¶
MarshalText implements encoding.TextMarshaler. It returns an empty string if invalid, otherwise datetime.DateTime's MarshalText.
func (DateTime) Ptr ¶
Ptr returns a pointer to this DateTime's value, or a nil pointer if this DateTime is null.
func (*DateTime) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports string and null input.
func (*DateTime) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler. It has backwards compatibility with v3 in that the string "null" is considered equivalent to an empty string and unmarshaling will succeed. This may be removed in a future version.
func (DateTime) ValueOrZero ¶
ValueOrZero returns the inner value if valid, otherwise zero.
type Decimal ¶
type Decimal struct {
dec.NullDecimal
}
Decimal is a nullable decimal.Decimal. It supports SQL and JSON serialization. It will marshal to null if null.
func DecimalFrom ¶
DecimalFrom creates a new Decimal that will always be valid.
func DecimalFromPtr ¶
DecimalFromPtr creates a new Decimal that will be null if d is nil.
func NewDecimal ¶
NewDecimal creates a new Decimal.
func (Decimal) ExactEqual ¶
ExactEqual returns true if both Decimal objects are exactly equal or both null. Unlike Equal, this requires the underlying representation to be identical.
func (Decimal) IsZero ¶
IsZero returns true for invalid Decimals, for future omitempty support. A non-null Decimal with a zero value will not be considered zero.
func (Decimal) Ptr ¶
Ptr returns a pointer to this Decimal's value, or a nil pointer if this Decimal is null.
func (Decimal) ValueOrZero ¶
ValueOrZero returns the inner value if valid, otherwise zero.
type Time ¶
Time is a nullable datetime.Time. It supports SQL and JSON serialization. It will marshal to null if null.
func TimeFromPtr ¶
TimeFromPtr creates a new Time that will be null if t is nil.
func (Time) Equal ¶
Equal returns true if both Time objects encode the same time or are both null. Two times can be equal even if they are in different locations. For example, 6:00 +0200 CEST and 4:00 UTC are Equal.
func (Time) ExactEqual ¶
ExactEqual returns true if both Time objects are equal or both null. ExactEqual returns false for times that are in different locations or have a different monotonic clock reading.
func (Time) IsZero ¶
IsZero returns true for invalid Times, hopefully for future omitempty support. A non-null Time with a zero value will not be considered zero.
func (Time) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this time is null.
func (Time) MarshalText ¶
MarshalText implements encoding.TextMarshaler. It returns an empty string if invalid, otherwise datetime.Time's MarshalText.
func (Time) Ptr ¶
Ptr returns a pointer to this Time's value, or a nil pointer if this Time is null.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports string and null input.
func (*Time) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler. It has backwards compatibility with v3 in that the string "null" is considered equivalent to an empty string and unmarshaling will succeed. This may be removed in a future version.
func (Time) ValueOrZero ¶
ValueOrZero returns the inner value if valid, otherwise zero.