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.
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.
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
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.
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
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).
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
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.
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
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.
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
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.
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
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.
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
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.
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
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.
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
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.
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