Documentation ¶
Overview ¶
Package sqltypes implements interfaces and types that represent SQL values.
Index ¶
- Variables
- type BinWriter
- type Fractional
- type InnerValue
- type Numeric
- type String
- type Value
- func (v Value) EncodeAscii(b BinWriter)
- func (v Value) EncodeSql(b BinWriter)
- func (v Value) IsFractional() (ok bool)
- func (v Value) IsNull() bool
- func (v Value) IsNumeric() (ok bool)
- func (v Value) IsString() (ok bool)
- func (v Value) MarshalJSON() ([]byte, error)
- func (v Value) ParseInt64() (val int64, err error)
- func (v Value) ParseUint64() (val uint64, err error)
- func (v Value) Raw() []byte
- func (v Value) String() string
Constants ¶
This section is empty.
Variables ¶
var ( NULL = Value{} DONTESCAPE = byte(255) )
var SqlDecodeMap [256]byte
SqlDecodeMap is the reverse of SqlEncodeMap
var SqlEncodeMap [256]byte
SqlEncodeMap specifies how to escape binary data with '\'. Complies to http://dev.mysql.com/doc/refman/5.1/en/string-syntax.html
Functions ¶
This section is empty.
Types ¶
type BinWriter ¶
BinWriter interface is used for encoding values. Types like bytes.Buffer conform to this interface. We expect the writer objects to be in-memory buffers. So, we don't expect the write operations to fail.
type Fractional ¶
type Fractional []byte
Fractional represents fractional types like float and decimal It's functionally equivalent to Numeric other than how it's constructed
type InnerValue ¶
type InnerValue interface {
// contains filtered or unexported methods
}
InnerValue defines methods that need to be supported by all non-null value types.
type Numeric ¶
type Numeric []byte
Numeric represents non-fractional SQL number.
func (Numeric) MarshalJSON ¶
type String ¶
type String []byte
String represents any SQL type that needs to be represented using quotes.
type Value ¶
type Value struct {
Inner InnerValue
}
Value can store any SQL value. NULL is stored as nil.
func BuildNumeric ¶
BuildNumeric builds a Numeric type that represents any whole number. It normalizes the representation to ensure 1:1 mapping between the number and its representation.
func BuildValue ¶
func MakeFractional ¶
MakeFractional makes a Fractional value from a []byte without validation.
func MakeNumeric ¶
MakeNumeric makes a Numeric from a []byte without validation.
func (Value) EncodeAscii ¶
EncodeAscii encodes the value using 7-bit clean ascii bytes.
func (Value) IsFractional ¶
func (Value) MarshalJSON ¶
func (Value) ParseInt64 ¶
ParseInt64 will parse a Numeric value into an int64
func (Value) ParseUint64 ¶
ParseUint64 will parse a Numeric value into a uint64