types

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrColumnNotFound must be returned by row implementations, when calling the Get method and
	// the column doesn't exist.
	ErrColumnNotFound = errors.New("column not found")
)

Functions

func AsBool added in v0.17.0

func AsBool(v Value) bool

func AsByteSlice added in v0.17.0

func AsByteSlice(v Value) []byte

func AsFloat64 added in v0.17.0

func AsFloat64(v Value) float64

func AsInt32 added in v0.17.0

func AsInt32(v Value) int32

func AsInt64 added in v0.17.0

func AsInt64(v Value) int64

func AsString added in v0.17.0

func AsString(v Value) string

func AsTime added in v0.17.0

func AsTime(v Value) time.Time

func Desc added in v0.17.0

func Desc(dst []byte, n int) ([]byte, int)

Desc changes the type of the encoded value to its descending counterpart. It is meant to be used in combination with one of the Encode* functions.

var buf []byte
buf, n = encoding.Desc(encoding.EncodeInt(buf, 10))

func EncodeValueAsKey added in v0.17.0

func EncodeValueAsKey(dst []byte, v Value, desc bool) ([]byte, error)

func EncodeValuesAsKey added in v0.17.0

func EncodeValuesAsKey(dst []byte, values ...Value) ([]byte, error)

func IsNull

func IsNull(v Value) bool

func IsTruthy

func IsTruthy(v Value) (bool, error)

IsTruthy returns whether v is not Equal to the zero value of its type.

func ParseTimestamp

func ParseTimestamp(s string) (time.Time, error)

Types

type BigintTypeDef added in v0.17.0

type BigintTypeDef struct{}

func (BigintTypeDef) Decode added in v0.17.0

func (BigintTypeDef) Decode(src []byte) (Value, int)

func (BigintTypeDef) IsComparableWith added in v0.17.0

func (BigintTypeDef) IsComparableWith(other Type) bool

func (BigintTypeDef) IsIndexComparableWith added in v0.17.0

func (BigintTypeDef) IsIndexComparableWith(other Type) bool

type BigintValue added in v0.17.0

type BigintValue int64

func NewBigintValue added in v0.17.0

func NewBigintValue(x int64) BigintValue

NewBigintValue returns a SQL BIGINT value.

func (BigintValue) Add added in v0.17.0

func (v BigintValue) Add(other Numeric) (Value, error)

func (BigintValue) Between added in v0.17.0

func (v BigintValue) Between(a, b Value) (bool, error)

func (BigintValue) BitwiseAnd added in v0.17.0

func (v BigintValue) BitwiseAnd(other Numeric) (Value, error)

func (BigintValue) BitwiseOr added in v0.17.0

func (v BigintValue) BitwiseOr(other Numeric) (Value, error)

func (BigintValue) BitwiseXor added in v0.17.0

func (v BigintValue) BitwiseXor(other Numeric) (Value, error)

func (BigintValue) CastAs added in v0.17.0

func (v BigintValue) CastAs(target Type) (Value, error)

func (BigintValue) Div added in v0.17.0

func (v BigintValue) Div(other Numeric) (Value, error)

func (BigintValue) EQ added in v0.17.0

func (v BigintValue) EQ(other Value) (bool, error)

func (BigintValue) Encode added in v0.17.0

func (v BigintValue) Encode(dst []byte) ([]byte, error)

func (BigintValue) EncodeAsKey added in v0.17.0

func (v BigintValue) EncodeAsKey(dst []byte) ([]byte, error)

func (BigintValue) GT added in v0.17.0

func (v BigintValue) GT(other Value) (bool, error)

func (BigintValue) GTE added in v0.17.0

func (v BigintValue) GTE(other Value) (bool, error)

func (BigintValue) IsZero added in v0.17.0

func (v BigintValue) IsZero() (bool, error)

func (BigintValue) LT added in v0.17.0

func (v BigintValue) LT(other Value) (bool, error)

func (BigintValue) LTE added in v0.17.0

func (v BigintValue) LTE(other Value) (bool, error)

func (BigintValue) MarshalJSON added in v0.17.0

func (v BigintValue) MarshalJSON() ([]byte, error)

func (BigintValue) MarshalText added in v0.17.0

func (v BigintValue) MarshalText() ([]byte, error)

func (BigintValue) Mod added in v0.17.0

func (v BigintValue) Mod(other Numeric) (Value, error)

func (BigintValue) Mul added in v0.17.0

func (v BigintValue) Mul(other Numeric) (Value, error)

func (BigintValue) String added in v0.17.0

func (v BigintValue) String() string

func (BigintValue) Sub added in v0.17.0

func (v BigintValue) Sub(other Numeric) (Value, error)

func (BigintValue) Type added in v0.17.0

func (v BigintValue) Type() Type

func (BigintValue) TypeDef added in v0.17.0

func (v BigintValue) TypeDef() TypeDefinition

func (BigintValue) V added in v0.17.0

func (v BigintValue) V() any

type BooleanTypeDef added in v0.17.0

type BooleanTypeDef struct{}

func (BooleanTypeDef) Decode added in v0.17.0

func (t BooleanTypeDef) Decode(src []byte) (Value, int)

func (BooleanTypeDef) IsComparableWith added in v0.17.0

func (BooleanTypeDef) IsComparableWith(other Type) bool

func (BooleanTypeDef) IsIndexComparableWith added in v0.17.0

func (BooleanTypeDef) IsIndexComparableWith(other Type) bool

type BooleanValue

type BooleanValue bool

func NewBooleanValue added in v0.17.0

func NewBooleanValue(x bool) BooleanValue

NewBooleanValue returns a SQL BOOLEAN value.

func (BooleanValue) Between added in v0.17.0

func (v BooleanValue) Between(a, b Value) (bool, error)

func (BooleanValue) CastAs added in v0.17.0

func (v BooleanValue) CastAs(target Type) (Value, error)

func (BooleanValue) ConvertToIndexedType added in v0.17.0

func (v BooleanValue) ConvertToIndexedType(t Type) (Value, error)

func (BooleanValue) EQ added in v0.17.0

func (v BooleanValue) EQ(other Value) (bool, error)

func (BooleanValue) Encode added in v0.17.0

func (v BooleanValue) Encode(dst []byte) ([]byte, error)

func (BooleanValue) EncodeAsKey added in v0.17.0

func (v BooleanValue) EncodeAsKey(dst []byte) ([]byte, error)

func (BooleanValue) GT added in v0.17.0

func (v BooleanValue) GT(other Value) (bool, error)

func (BooleanValue) GTE added in v0.17.0

func (v BooleanValue) GTE(other Value) (bool, error)

func (BooleanValue) IsZero added in v0.17.0

func (v BooleanValue) IsZero() (bool, error)

func (BooleanValue) LT added in v0.17.0

func (v BooleanValue) LT(other Value) (bool, error)

func (BooleanValue) LTE added in v0.17.0

func (v BooleanValue) LTE(other Value) (bool, error)

func (BooleanValue) MarshalJSON added in v0.17.0

func (v BooleanValue) MarshalJSON() ([]byte, error)

func (BooleanValue) MarshalText added in v0.17.0

func (v BooleanValue) MarshalText() ([]byte, error)

func (BooleanValue) String added in v0.17.0

func (v BooleanValue) String() string

func (BooleanValue) Type added in v0.17.0

func (v BooleanValue) Type() Type

func (BooleanValue) TypeDef added in v0.17.0

func (v BooleanValue) TypeDef() TypeDefinition

func (BooleanValue) V added in v0.17.0

func (v BooleanValue) V() any

type ByteaTypeDef added in v0.18.0

type ByteaTypeDef struct{}

func (ByteaTypeDef) Decode added in v0.18.0

func (ByteaTypeDef) Decode(src []byte) (Value, int)

func (ByteaTypeDef) IsComparableWith added in v0.18.0

func (ByteaTypeDef) IsComparableWith(other Type) bool

func (ByteaTypeDef) IsIndexComparableWith added in v0.18.0

func (ByteaTypeDef) IsIndexComparableWith(other Type) bool

type ByteaValue added in v0.18.0

type ByteaValue []byte

func NewByteaValue added in v0.18.0

func NewByteaValue(x []byte) ByteaValue

NewByteaValue returns a SQL BYTEA value.

func (ByteaValue) Between added in v0.18.0

func (v ByteaValue) Between(a, b Value) (bool, error)

func (ByteaValue) CastAs added in v0.18.0

func (v ByteaValue) CastAs(target Type) (Value, error)

func (ByteaValue) EQ added in v0.18.0

func (v ByteaValue) EQ(other Value) (bool, error)

func (ByteaValue) Encode added in v0.18.0

func (v ByteaValue) Encode(dst []byte) ([]byte, error)

func (ByteaValue) EncodeAsKey added in v0.18.0

func (v ByteaValue) EncodeAsKey(dst []byte) ([]byte, error)

func (ByteaValue) GT added in v0.18.0

func (v ByteaValue) GT(other Value) (bool, error)

func (ByteaValue) GTE added in v0.18.0

func (v ByteaValue) GTE(other Value) (bool, error)

func (ByteaValue) IsZero added in v0.18.0

func (v ByteaValue) IsZero() (bool, error)

func (ByteaValue) LT added in v0.18.0

func (v ByteaValue) LT(other Value) (bool, error)

func (ByteaValue) LTE added in v0.18.0

func (v ByteaValue) LTE(other Value) (bool, error)

func (ByteaValue) MarshalJSON added in v0.18.0

func (v ByteaValue) MarshalJSON() ([]byte, error)

func (ByteaValue) MarshalText added in v0.18.0

func (v ByteaValue) MarshalText() ([]byte, error)

func (ByteaValue) String added in v0.18.0

func (v ByteaValue) String() string

func (ByteaValue) Type added in v0.18.0

func (v ByteaValue) Type() Type

func (ByteaValue) TypeDef added in v0.18.0

func (v ByteaValue) TypeDef() TypeDefinition

func (ByteaValue) V added in v0.18.0

func (v ByteaValue) V() any

type Comparable added in v0.17.0

type Comparable interface {
	EQ(other Value) (bool, error)
	GT(other Value) (bool, error)
	GTE(other Value) (bool, error)
	LT(other Value) (bool, error)
	LTE(other Value) (bool, error)
	Between(a, b Value) (bool, error)
}

type DoublePrecisionTypeDef added in v0.18.0

type DoublePrecisionTypeDef struct{}

func (DoublePrecisionTypeDef) Decode added in v0.18.0

func (DoublePrecisionTypeDef) Decode(src []byte) (Value, int)

func (DoublePrecisionTypeDef) IsComparableWith added in v0.18.0

func (DoublePrecisionTypeDef) IsComparableWith(other Type) bool

func (DoublePrecisionTypeDef) IsIndexComparableWith added in v0.18.0

func (DoublePrecisionTypeDef) IsIndexComparableWith(other Type) bool

type DoublePrecisionValue added in v0.18.0

type DoublePrecisionValue float64

func NewDoublePrecisionValue added in v0.18.0

func NewDoublePrecisionValue(x float64) DoublePrecisionValue

NewDoublePrecisionValue returns a SQL DOUBLE PRECISION value.

func (DoublePrecisionValue) Add added in v0.18.0

func (v DoublePrecisionValue) Add(other Numeric) (Value, error)

func (DoublePrecisionValue) Between added in v0.18.0

func (v DoublePrecisionValue) Between(a, b Value) (bool, error)

func (DoublePrecisionValue) CastAs added in v0.18.0

func (v DoublePrecisionValue) CastAs(target Type) (Value, error)

func (DoublePrecisionValue) Div added in v0.18.0

func (v DoublePrecisionValue) Div(other Numeric) (Value, error)

func (DoublePrecisionValue) EQ added in v0.18.0

func (v DoublePrecisionValue) EQ(other Value) (bool, error)

func (DoublePrecisionValue) Encode added in v0.18.0

func (v DoublePrecisionValue) Encode(dst []byte) ([]byte, error)

func (DoublePrecisionValue) EncodeAsKey added in v0.18.0

func (v DoublePrecisionValue) EncodeAsKey(dst []byte) ([]byte, error)

func (DoublePrecisionValue) GT added in v0.18.0

func (v DoublePrecisionValue) GT(other Value) (bool, error)

func (DoublePrecisionValue) GTE added in v0.18.0

func (v DoublePrecisionValue) GTE(other Value) (bool, error)

func (DoublePrecisionValue) IsZero added in v0.18.0

func (v DoublePrecisionValue) IsZero() (bool, error)

func (DoublePrecisionValue) LT added in v0.18.0

func (v DoublePrecisionValue) LT(other Value) (bool, error)

func (DoublePrecisionValue) LTE added in v0.18.0

func (v DoublePrecisionValue) LTE(other Value) (bool, error)

func (DoublePrecisionValue) MarshalJSON added in v0.18.0

func (v DoublePrecisionValue) MarshalJSON() ([]byte, error)

func (DoublePrecisionValue) MarshalText added in v0.18.0

func (v DoublePrecisionValue) MarshalText() ([]byte, error)

func (DoublePrecisionValue) Mod added in v0.18.0

func (v DoublePrecisionValue) Mod(other Numeric) (Value, error)

func (DoublePrecisionValue) Mul added in v0.18.0

func (v DoublePrecisionValue) Mul(other Numeric) (Value, error)

func (DoublePrecisionValue) String added in v0.18.0

func (v DoublePrecisionValue) String() string

func (DoublePrecisionValue) Sub added in v0.18.0

func (v DoublePrecisionValue) Sub(other Numeric) (Value, error)

func (DoublePrecisionValue) Type added in v0.18.0

func (v DoublePrecisionValue) Type() Type

func (DoublePrecisionValue) TypeDef added in v0.18.0

func (DoublePrecisionValue) V added in v0.18.0

func (v DoublePrecisionValue) V() any

type IntegerTypeDef added in v0.17.0

type IntegerTypeDef struct{}

func (IntegerTypeDef) Decode added in v0.17.0

func (IntegerTypeDef) Decode(src []byte) (Value, int)

func (IntegerTypeDef) IsComparableWith added in v0.17.0

func (IntegerTypeDef) IsComparableWith(other Type) bool

func (IntegerTypeDef) IsIndexComparableWith added in v0.17.0

func (IntegerTypeDef) IsIndexComparableWith(other Type) bool

type IntegerValue

type IntegerValue int32

func NewIntegerValue

func NewIntegerValue(x int32) IntegerValue

NewIntegerValue returns a SQL INTEGER value.

func (IntegerValue) Add added in v0.17.0

func (v IntegerValue) Add(other Numeric) (Value, error)

func (IntegerValue) Between added in v0.17.0

func (v IntegerValue) Between(a, b Value) (bool, error)

func (IntegerValue) BitwiseAnd added in v0.17.0

func (v IntegerValue) BitwiseAnd(other Numeric) (Value, error)

func (IntegerValue) BitwiseOr added in v0.17.0

func (v IntegerValue) BitwiseOr(other Numeric) (Value, error)

func (IntegerValue) BitwiseXor added in v0.17.0

func (v IntegerValue) BitwiseXor(other Numeric) (Value, error)

func (IntegerValue) CastAs added in v0.17.0

func (v IntegerValue) CastAs(target Type) (Value, error)

func (IntegerValue) Div added in v0.17.0

func (v IntegerValue) Div(other Numeric) (Value, error)

func (IntegerValue) EQ added in v0.17.0

func (v IntegerValue) EQ(other Value) (bool, error)

func (IntegerValue) Encode added in v0.17.0

func (v IntegerValue) Encode(dst []byte) ([]byte, error)

func (IntegerValue) EncodeAsKey added in v0.17.0

func (v IntegerValue) EncodeAsKey(dst []byte) ([]byte, error)

func (IntegerValue) GT added in v0.17.0

func (v IntegerValue) GT(other Value) (bool, error)

func (IntegerValue) GTE added in v0.17.0

func (v IntegerValue) GTE(other Value) (bool, error)

func (IntegerValue) IsZero added in v0.17.0

func (v IntegerValue) IsZero() (bool, error)

func (IntegerValue) LT added in v0.17.0

func (v IntegerValue) LT(other Value) (bool, error)

func (IntegerValue) LTE added in v0.17.0

func (v IntegerValue) LTE(other Value) (bool, error)

func (IntegerValue) MarshalJSON added in v0.17.0

func (v IntegerValue) MarshalJSON() ([]byte, error)

func (IntegerValue) MarshalText added in v0.17.0

func (v IntegerValue) MarshalText() ([]byte, error)

func (IntegerValue) Mod added in v0.17.0

func (v IntegerValue) Mod(other Numeric) (Value, error)

func (IntegerValue) Mul added in v0.17.0

func (v IntegerValue) Mul(other Numeric) (Value, error)

func (IntegerValue) String added in v0.17.0

func (v IntegerValue) String() string

func (IntegerValue) Sub added in v0.17.0

func (v IntegerValue) Sub(other Numeric) (Value, error)

func (IntegerValue) Type added in v0.17.0

func (v IntegerValue) Type() Type

func (IntegerValue) TypeDef added in v0.17.0

func (v IntegerValue) TypeDef() TypeDefinition

func (IntegerValue) V added in v0.17.0

func (v IntegerValue) V() any

type Integral added in v0.17.0

type Integral interface {
	// BitwiseAnd calculates v & u and returns the result.
	// Only numeric values and booleans can be calculated together.
	// If both v and u are integers, the result will be an integer.
	BitwiseAnd(other Numeric) (Value, error)
	// BitwiseOr calculates v | u and returns the result.
	// Only numeric values and booleans can be calculated together.
	// If both v and u are integers, the result will be an integer.
	BitwiseOr(other Numeric) (Value, error)
	// BitwiseXor calculates v ^ u and returns the result.
	// Only numeric values and booleans can be calculated together.
	// If both v and u are integers, the result will be an integer.
	BitwiseXor(other Numeric) (Value, error)
}

type NullTypeDef added in v0.17.0

type NullTypeDef struct{}

func (NullTypeDef) Decode added in v0.17.0

func (NullTypeDef) Decode(src []byte) (Value, int)

func (NullTypeDef) IsComparableWith added in v0.17.0

func (NullTypeDef) IsComparableWith(other Type) bool

func (NullTypeDef) IsIndexComparableWith added in v0.17.0

func (NullTypeDef) IsIndexComparableWith(other Type) bool

type NullValue

type NullValue struct{}

func NewNullValue

func NewNullValue() NullValue

NewNullValue returns a SQL NULL value.

func (NullValue) Between added in v0.17.0

func (v NullValue) Between(a, b Value) (bool, error)

func (NullValue) CastAs added in v0.17.0

func (v NullValue) CastAs(target Type) (Value, error)

func (NullValue) EQ added in v0.17.0

func (v NullValue) EQ(other Value) (bool, error)

func (NullValue) Encode added in v0.17.0

func (v NullValue) Encode(dst []byte) ([]byte, error)

func (NullValue) EncodeAsKey added in v0.17.0

func (v NullValue) EncodeAsKey(dst []byte) ([]byte, error)

func (NullValue) GT added in v0.17.0

func (v NullValue) GT(other Value) (bool, error)

func (NullValue) GTE added in v0.17.0

func (v NullValue) GTE(other Value) (bool, error)

func (NullValue) IsZero added in v0.17.0

func (v NullValue) IsZero() (bool, error)

func (NullValue) LT added in v0.17.0

func (v NullValue) LT(other Value) (bool, error)

func (NullValue) LTE added in v0.17.0

func (v NullValue) LTE(other Value) (bool, error)

func (NullValue) MarshalJSON added in v0.17.0

func (v NullValue) MarshalJSON() ([]byte, error)

func (NullValue) MarshalText added in v0.17.0

func (v NullValue) MarshalText() ([]byte, error)

func (NullValue) String added in v0.17.0

func (v NullValue) String() string

func (NullValue) Type added in v0.17.0

func (v NullValue) Type() Type

func (NullValue) TypeDef added in v0.17.0

func (v NullValue) TypeDef() TypeDefinition

func (NullValue) V added in v0.17.0

func (v NullValue) V() any

type Numeric added in v0.17.0

type Numeric interface {
	Value

	// Add u to v and return the result.
	// Only numeric values and booleans can be added together.
	Add(other Numeric) (Value, error)
	// Sub calculates v - u and returns the result.
	// Only numeric values and booleans can be calculated together.
	Sub(other Numeric) (Value, error)
	// Mul calculates v * u and returns the result.
	// Only numeric values and booleans can be calculated together.
	Mul(other Numeric) (Value, error)
	// Div calculates v / u and returns the result.
	// Only numeric values and booleans can be calculated together.
	// If both v and u are integers, the result will be an integer.
	Div(other Numeric) (Value, error)
	// Mod calculates v / u and returns the result.
	// Only numeric values and booleans can be calculated together.
	// If both v and u are integers, the result will be an integer.
	Mod(other Numeric) (Value, error)
}

type TextTypeDef added in v0.17.0

type TextTypeDef struct{}

func (TextTypeDef) Decode added in v0.17.0

func (TextTypeDef) Decode(src []byte) (Value, int)

func (TextTypeDef) IsComparableWith added in v0.17.0

func (TextTypeDef) IsComparableWith(other Type) bool

func (TextTypeDef) IsIndexComparableWith added in v0.17.0

func (t TextTypeDef) IsIndexComparableWith(other Type) bool

type TextValue

type TextValue string

func NewTextValue

func NewTextValue(x string) TextValue

NewTextValue returns a SQL TEXT value.

func (TextValue) Between added in v0.17.0

func (v TextValue) Between(a, b Value) (bool, error)

func (TextValue) CastAs added in v0.17.0

func (v TextValue) CastAs(target Type) (Value, error)

func (TextValue) EQ added in v0.17.0

func (v TextValue) EQ(other Value) (bool, error)

func (TextValue) Encode added in v0.17.0

func (v TextValue) Encode(dst []byte) ([]byte, error)

func (TextValue) EncodeAsKey added in v0.17.0

func (v TextValue) EncodeAsKey(dst []byte) ([]byte, error)

func (TextValue) GT added in v0.17.0

func (v TextValue) GT(other Value) (bool, error)

func (TextValue) GTE added in v0.17.0

func (v TextValue) GTE(other Value) (bool, error)

func (TextValue) IsZero added in v0.17.0

func (v TextValue) IsZero() (bool, error)

func (TextValue) LT added in v0.17.0

func (v TextValue) LT(other Value) (bool, error)

func (TextValue) LTE added in v0.17.0

func (v TextValue) LTE(other Value) (bool, error)

func (TextValue) MarshalJSON added in v0.17.0

func (v TextValue) MarshalJSON() ([]byte, error)

func (TextValue) MarshalText added in v0.17.0

func (v TextValue) MarshalText() ([]byte, error)

func (TextValue) String added in v0.17.0

func (v TextValue) String() string

func (TextValue) Type added in v0.17.0

func (v TextValue) Type() Type

func (TextValue) TypeDef added in v0.17.0

func (v TextValue) TypeDef() TypeDefinition

func (TextValue) V added in v0.17.0

func (v TextValue) V() any

type TimestampTypeDef added in v0.17.0

type TimestampTypeDef struct{}

func (TimestampTypeDef) Decode added in v0.17.0

func (t TimestampTypeDef) Decode(src []byte) (Value, int)

func (TimestampTypeDef) IsComparableWith added in v0.17.0

func (TimestampTypeDef) IsComparableWith(other Type) bool

func (TimestampTypeDef) IsIndexComparableWith added in v0.17.0

func (TimestampTypeDef) IsIndexComparableWith(other Type) bool

type TimestampValue

type TimestampValue time.Time

func NewTimestampValue

func NewTimestampValue(x time.Time) TimestampValue

NewTimestampValue returns a SQL TIMESTAMP value.

func (TimestampValue) Between added in v0.17.0

func (v TimestampValue) Between(a, b Value) (bool, error)

func (TimestampValue) CastAs added in v0.17.0

func (v TimestampValue) CastAs(target Type) (Value, error)

func (TimestampValue) EQ added in v0.17.0

func (v TimestampValue) EQ(other Value) (bool, error)

func (TimestampValue) Encode added in v0.17.0

func (v TimestampValue) Encode(dst []byte) ([]byte, error)

func (TimestampValue) EncodeAsKey added in v0.17.0

func (v TimestampValue) EncodeAsKey(dst []byte) ([]byte, error)

func (TimestampValue) GT added in v0.17.0

func (v TimestampValue) GT(other Value) (bool, error)

func (TimestampValue) GTE added in v0.17.0

func (v TimestampValue) GTE(other Value) (bool, error)

func (TimestampValue) IsZero added in v0.17.0

func (v TimestampValue) IsZero() (bool, error)

func (TimestampValue) LT added in v0.17.0

func (v TimestampValue) LT(other Value) (bool, error)

func (TimestampValue) LTE added in v0.17.0

func (v TimestampValue) LTE(other Value) (bool, error)

func (TimestampValue) MarshalJSON added in v0.17.0

func (v TimestampValue) MarshalJSON() ([]byte, error)

func (TimestampValue) MarshalText added in v0.17.0

func (v TimestampValue) MarshalText() ([]byte, error)

func (TimestampValue) String added in v0.17.0

func (v TimestampValue) String() string

func (TimestampValue) Type added in v0.17.0

func (v TimestampValue) Type() Type

func (TimestampValue) TypeDef added in v0.17.0

func (v TimestampValue) TypeDef() TypeDefinition

func (TimestampValue) V added in v0.17.0

func (v TimestampValue) V() any

type Type added in v0.17.0

type Type uint8

Type represents a type supported by the database.

const (
	// TypeAny denotes the absence of type
	TypeAny Type = iota
	TypeNull
	TypeBoolean
	TypeInteger
	TypeBigint
	TypeDoublePrecision
	TypeTimestamp
	TypeText
	TypeBytea
)

List of supported types.

func (Type) Def added in v0.17.0

func (t Type) Def() TypeDefinition

func (Type) IsAny added in v0.17.0

func (t Type) IsAny() bool

IsAny returns whether this is type is Any or a real type

func (Type) IsComparableWith added in v0.17.0

func (t Type) IsComparableWith(other Type) bool

func (Type) IsInteger added in v0.17.0

func (t Type) IsInteger() bool

func (Type) IsNumber added in v0.17.0

func (t Type) IsNumber() bool

IsNumber returns true if t is either an integer or a float.

func (Type) IsTimestampCompatible added in v0.17.0

func (t Type) IsTimestampCompatible() bool

IsTimestampCompatible returns true if t is either a timestamp, an integer, or a text.

func (Type) MaxEnctype added in v0.17.0

func (t Type) MaxEnctype() byte

func (Type) MaxEnctypeDesc added in v0.17.0

func (t Type) MaxEnctypeDesc() byte

func (Type) MinEnctype added in v0.17.0

func (t Type) MinEnctype() byte

func (Type) MinEnctypeDesc added in v0.17.0

func (t Type) MinEnctypeDesc() byte

func (Type) String added in v0.17.0

func (t Type) String() string

type TypeDefinition added in v0.17.0

type TypeDefinition interface {
	Decode(src []byte) (Value, int)
	IsComparableWith(other Type) bool
	IsIndexComparableWith(other Type) bool
}

type Value

type Value interface {
	Comparable

	Type() Type
	V() any
	IsZero() (bool, error)
	String() string
	MarshalJSON() ([]byte, error)
	MarshalText() ([]byte, error)
	TypeDef() TypeDefinition
	Encode(dst []byte) ([]byte, error)
	EncodeAsKey(dst []byte) ([]byte, error)
	CastAs(t Type) (Value, error)
}

func DecodeValue added in v0.17.0

func DecodeValue(b []byte) (v Value, n int)

func DecodeValues added in v0.17.0

func DecodeValues(b []byte) []Value

type ValueScanner added in v0.17.0

type ValueScanner struct {
	V Value
}

ValueScanner implements the sql.Scanner interface for Value. The src value will be of one of the following types:

int32
int64
float64
bool
[]byte
string
time.Time
nil - for NULL values

func (*ValueScanner) Scan added in v0.17.0

func (v *ValueScanner) Scan(src any) error

Jump to

Keyboard shortcuts

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