null

package
v0.9.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(n Nullable, value any) bool

Compare checks value against the value stored with Nullable. It returns true when: - nullable is valid and value of nullable is equal to given value, - or when nullable is not valid (SQL NULL) and value is nil

Panics when value cannot be used with given Nullable n.

Types

type Bytes

type Bytes struct {
	Bytes []byte
	Valid bool
}

Bytes represents a []byte (any MySQL BINARY types) that may be NULL. This is not available in Go's sql package, and does not implement the Scanner interface.

func (Bytes) Compare

func (n Bytes) Compare(value any) bool

Compare returns whether value compares with the nullable Bytes. It returns: - true when Valid and stored Bytes is equal to value - true when not Valid and value is nil - false in any other case

func (Bytes) Value

func (n Bytes) Value() (driver.Value, error)

Value returns the value of n and implements the driver.Valuer as well as Nullable interface.

type Decimal

type Decimal struct {
	Decimal decimal.Decimal
	Valid   bool
}

Decimal represents a decimal.Decimal (MySQL DECIMAL type) that may be NULL. This is similar to types provided by Go's sql package, and does not implement the Scanner interface.

func (Decimal) Compare

func (nd Decimal) Compare(value any) bool

Compare returns whether value compares with the nullable Decimal. It returns: - true when Valid and stored Decimal is equal to value - true when not Valid and value is nil - false in any other case

func (Decimal) Value

func (nd Decimal) Value() (driver.Value, error)

Value returns the value of n and implements the driver.Valuer as well as Nullable interface.

type Duration

type Duration struct {
	Duration time.Duration
	Valid    bool
}

Duration represents a time.Duration (MySQL TIME type) that may be NULL. This is not available in Go's sql package, and does not implement the Scanner interface. Note that the sql.NullTime is for timestamps (which includes dates).

func (Duration) Compare

func (nd Duration) Compare(value any) bool

Compare returns whether value compares with the nullable Duration. It returns: - true when Valid and stored Duration is equal to value - true when not Valid and value is nil - false in any other case

func (Duration) Value

func (nd Duration) Value() (driver.Value, error)

Value returns the value of n and implements the driver.Valuer as well as Nullable interface.

type Float32

type Float32 struct {
	Float32 float32
	Valid   bool
}

Float32 represents a float32 (any MySQL FLOAT type) that may be NULL. This is similar to sql.NullFloat64, and does not implement the Scanner interface.

func (Float32) Compare

func (nf Float32) Compare(value any) bool

Compare returns whether value compares with the nullable Float32. It returns: - true when Valid and stored Float32 is equal to value - true when not Valid and value is nil - false in any other case

func (Float32) Value

func (nf Float32) Value() (driver.Value, error)

Value returns the value of n and implements the driver.Valuer as well as Nullable interface.

type Float64

type Float64 struct {
	Float64 float64
	Valid   bool
}

Float64 represents a float64 (any MySQL float/double type) that may be NULL. This is similar to sql.NullFloat64, and does not implement the Scanner interface.

func (Float64) Compare

func (nf Float64) Compare(value any) bool

Compare returns whether value compares with the nullable Float64. It returns: - true when Valid and stored Float64 is equal to value - true when not Valid and value is nil - false in any other case

func (Float64) Value

func (nf Float64) Value() (driver.Value, error)

Value returns the value of n and implements the driver.Valuer as well as Nullable interface.

type Int64

type Int64 struct {
	Int64 int64
	Valid bool
}

Int64 represents an int64 (any MySQL signed integral type) that may be NULL. This is similar to sql.NullInt64, and does not implement the Scanner interface.

func (Int64) Compare

func (ni Int64) Compare(value any) bool

Compare returns whether value compares with the nullable Duration. It returns: - true when Valid and stored Duration is equal to value - true when not Valid and value is nil - false in any other case

func (Int64) Value

func (ni Int64) Value() (driver.Value, error)

Value returns the value of n and implements the driver.Valuer as well as Nullable interface.

type Nullable

type Nullable interface {
	Compare(any) bool
	Value() (driver.Value, error)
}

type String

type String struct {
	String string
	Valid  bool
}

String represents as string (any MySQL CHAR-kind of data type) that may be NULL. This is similar to sql.NullString, and does not implement the Scanner interface.

func (String) Compare

func (ns String) Compare(value any) bool

Compare returns whether value compares with the nullable String. It returns: - true when Valid and stored String is equal to value - true when not Valid and value is nil - false in any other case

func (String) Value

func (ns String) Value() (driver.Value, error)

Value returns the value of n and implements the driver.Valuer as well as Nullable interface.

type Strings

type Strings struct {
	Strings []string
	Valid   bool
}

Strings represents a []string (slice of strings), for example used for MySQL ENUM type, that may be NULL. This is not available in the Go's sql package, and does not implement the Scanner interface.

func (Strings) Compare

func (ns Strings) Compare(value any) bool

Compare returns whether value compares with the nullable Strings. It returns: - true when Valid and stored Strings is equal to value - true when not Valid and value is nil - false in any other case

func (Strings) Value

func (ns Strings) Value() (driver.Value, error)

Value returns the value of n and implements the driver.Valuer as well as Nullable interface.

type Time

type Time struct {
	Time  time.Time
	Valid bool
}

Time represents as string (MySQL TIMESTAMP, DATETIME, and DATE types) that may be NULL. This is similar to sql.NullTime, and does not implement the Scanner interface.

func (Time) Compare

func (nd Time) Compare(value any) bool

Compare returns whether value compares with the nullable Time. It returns: - true when Valid and stored Time is equal to value - true when not Valid and value is nil - false in any other case

func (Time) Value

func (nd Time) Value() (driver.Value, error)

Value returns the value of n and implements the driver.Valuer as well as Nullable interface.

type Uint64

type Uint64 struct {
	Uint64 uint64
	Valid  bool
}

Uint64 represents an uint64 (any MySQL unsigned integer type) that may be NULL. This is not available in Go's sql package, and does not implement the Scanner interface.

func (Uint64) Compare

func (ni Uint64) Compare(value any) bool

Compare returns whether value compares with the nullable Uint64. It returns: - true when Valid and stored Uint64 is equal to value - true when not Valid and value is nil - false in any other case

func (Uint64) Value

func (ni Uint64) Value() (driver.Value, error)

Value returns the value of n and implements the driver.Valuer as well as Nullable interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL