Documentation
¶
Overview ¶
Package types provides data type definitions for XxSql storage engine.
Index ¶
- func FormatDecimal(unscaled int64, scale int) string
- type CheckConstraintInfo
- type ColumnInfo
- type ForeignKeyInfo
- type TypeID
- type Value
- func NewBoolValue(v bool) Value
- func NewBytesValue(v []byte) Value
- func NewDateValue(v time.Time) Value
- func NewDatetimeValue(v time.Time) Value
- func NewDecimalFromString(s string) (Value, error)
- func NewDecimalValue(unscaled int64, scale int) Value
- func NewFloatValue(v float64) Value
- func NewIntValue(v int64) Value
- func NewNullValue() Value
- func NewStringValue(v string, typ TypeID) Value
- func NewTimeValue(v time.Time) Value
- func UnmarshalValue(data []byte, typ TypeID) (Value, int)
- func (v Value) AsBool() bool
- func (v Value) AsDatetime() time.Time
- func (v Value) AsDecimal() (unscaled int64, scale int)
- func (v Value) AsDecimalString() string
- func (v Value) AsFloat() float64
- func (v Value) AsInt() int64
- func (v Value) AsString() string
- func (v Value) Compare(other Value) int
- func (v Value) Marshal() []byte
- func (v Value) Size() int
- func (v Value) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatDecimal ¶
FormatDecimal formats an unscaled value with scale as a decimal string.
Types ¶
type CheckConstraintInfo ¶
type CheckConstraintInfo struct {
Name string `json:"name"`
Expression string `json:"expression"` // SQL expression as string
}
CheckConstraintInfo represents a CHECK constraint.
type ColumnInfo ¶
type ColumnInfo struct {
Name string
Type TypeID
Size int // For CHAR/VARCHAR
Precision int // For DECIMAL (not implemented yet)
Scale int // For DECIMAL (not implemented yet)
Nullable bool
Default Value
PrimaryKey bool
AutoIncr bool
Unique bool
Comment string
}
ColumnInfo represents column metadata.
type ForeignKeyInfo ¶
type ForeignKeyInfo struct {
Name string `json:"name"`
Columns []string `json:"columns"`
RefTable string `json:"ref_table"`
RefColumns []string `json:"ref_columns"`
OnDelete string `json:"on_delete"`
OnUpdate string `json:"on_update"`
}
ForeignKeyInfo represents a FOREIGN KEY constraint.
type Value ¶
Value represents a typed value.
func NewDatetimeValue ¶
NewDatetimeValue creates a datetime value.
func NewDecimalFromString ¶
NewDecimalFromString creates a DECIMAL value from a string representation.
func NewDecimalValue ¶
NewDecimalValue creates a DECIMAL value from an unscaled integer and scale. For example, NewDecimalValue(12345, 2) represents 123.45
func NewStringValue ¶
NewStringValue creates a string value (VARCHAR/CHAR/TEXT).
func UnmarshalValue ¶
UnmarshalValue deserializes bytes to a value.
func (Value) AsDatetime ¶
AsDatetime returns the value as time.Time.
func (Value) AsDecimal ¶
AsDecimal returns the unscaled value and scale for DECIMAL type. Returns (unscaled, scale) where the actual value is unscaled / 10^scale.
func (Value) AsDecimalString ¶
AsDecimalString returns the DECIMAL value as a string.