sql

package
v0.0.0-...-e7dff6c Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DateTime

type DateTime struct {
	time.Time
}

func NewDateTime

func NewDateTime(t time.Time) *DateTime

func (*DateTime) MarshalJSON

func (d *DateTime) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*DateTime) Scan

func (d *DateTime) Scan(src any) error

Scan implements the sql.Scanner interface.

func (DateTime) String

func (d DateTime) String() string

String implements the fmt.Stringer interface.

func (*DateTime) UnmarshalJSON

func (d *DateTime) UnmarshalJSON(text []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type Duration

type Duration time.Duration

Duration represents a mysql TIME column

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (*Duration) Scan

func (d *Duration) Scan(value interface{}) (err error)

Scan implements the Scanner interface

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

func (Duration) Value

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

Value implements the driver Valuer interface

type Enum

type Enum string

Enum represents non-nullable enum values in sql

func NewEnum

func NewEnum(s string) Enum

type NullBool

type NullBool struct {
	sql.NullBool
}

NullBool represents a nullable bool type which supports json Marshaler, sql Scanner, and sql driver Valuer interfaces.

func NewNullBool

func NewNullBool(b bool) *NullBool

NewNullBool returns a valid new NullBool for a given boolean value.

func (NullBool) MarshalJSON

func (r NullBool) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for a NullBool.

func (*NullBool) UnmarshalJSON

func (r *NullBool) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for a NullBool.

type NullDuration

type NullDuration struct {
	Duration
	Valid bool
}

NullDuration represents a nullable string type which supports json Marshaler, sql Scanner, and sql driver Valuer interfaces.

func NewNullDuration

func NewNullDuration(t time.Duration) *NullDuration

NewNullDuration returns a valid new NullDuration for a given time.Duration value.

func (NullDuration) MarshalJSON

func (r NullDuration) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for a NullDuration.

func (*NullDuration) UnmarshalJSON

func (r *NullDuration) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for a NullDuration.

type NullEnum

type NullEnum NullString

NullEnum represents nullable enum values in sql

func NewNullEnum

func NewNullEnum(s string) *NullEnum

NewNullEnum return a valid new NullEnum for a given value

type NullFloat64

type NullFloat64 struct {
	sql.NullFloat64
}

NullFloat64 represents a nullable float64 type which supports json Marshaler, sql Scanner, and sql driver Valuer interfaces.

func NewNullFloat64

func NewNullFloat64(f float64) *NullFloat64

NewNullFloat64 returns a valid new NullFloat64 for a given float64 value.

func (NullFloat64) MarshalJSON

func (r NullFloat64) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for a NullFloat64.

func (*NullFloat64) UnmarshalJSON

func (r *NullFloat64) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for a NullFloat64.

type NullInt64

type NullInt64 struct {
	sql.NullInt64
}

NullInt64 represents a nullable int64 type which supports json Marshaler, sql Scanner, and sql driver Valuer interfaces.

func NewNullInt64

func NewNullInt64(i int64) *NullInt64

NewNullInt64 returns a valid new NullInt64 for a given int64 value.

func (NullInt64) MarshalJSON

func (r NullInt64) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for a NullInt64.

func (NullInt64) RedisArg

func (r NullInt64) RedisArg() interface{}

RedisArg implements redis.Argument.

The caller should explicitly check the Valid field when putting NullString values into Redis. If this is not done it can lead to confusion as RedisScan on this type will treat an empty non-nil string as valid.

func (*NullInt64) RedisScan

func (r *NullInt64) RedisScan(src interface{}) error

RedisScan implements redis.Scanner.

func (*NullInt64) UnmarshalJSON

func (r *NullInt64) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for a NullInt64.

type NullString

type NullString struct {
	sql.NullString
}

NullString represents a nullable string type which supports json Marshaler, sql Scanner, and sql driver Valuer interfaces.

func NewNullString

func NewNullString(s string) *NullString

NewNullString returns a valid new NullString for a given string value.

func (NullString) MarshalJSON

func (r NullString) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for a NullString.

func (NullString) RedisArg

func (r NullString) RedisArg() interface{}

RedisArg implements redis.Argument.

The caller should explicitly check the Valid field when putting NullString values into Redis. If this is not done it can lead to confusion as RedisScan on this type will treat an empty non-nil string as valid.

func (*NullString) RedisScan

func (r *NullString) RedisScan(src interface{}) error

RedisScan implements redis.Scanner.

func (*NullString) UnmarshalJSON

func (r *NullString) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for a NullString.

type NullTime

type NullTime struct {
	sql.NullTime
}

NullTime represents a nullable string type which supports json.Marshaler, sql.Scanner, and sql/driver.Valuer interfaces.

func NewNullTime

func NewNullTime(t time.Time) *NullTime

NewNullTime returns a valid new NullTime for a given time.Time value.

func (NullTime) MarshalJSON

func (r NullTime) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaller.

func (NullTime) RedisArg

func (r NullTime) RedisArg() interface{}

RedisArg implements redis.Argument.

The time will be serialized as a UTC unix timestamp.

func (*NullTime) RedisScan

func (r *NullTime) RedisScan(src interface{}) error

RedisScan implements redis.Scanner.

The src value is expected to be a UTC timestamp formatted as a unix timestamp.

func (*NullTime) UnmarshalJSON

func (r *NullTime) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for a NullTime.

Jump to

Keyboard shortcuts

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