Add CORK self encoding to SQL objects
This commit is contained in:
parent
68c22bc25c
commit
b5da299ea3
4 changed files with 1333 additions and 61 deletions
2
glide.lock
generated
2
glide.lock
generated
|
@ -2,7 +2,7 @@ hash: 0402d462f75cf177f62e8a0c786da7e9ca6a22535e6412965b600141842d6dae
|
||||||
updated: 2016-10-29T14:57:11.583277704+01:00
|
updated: 2016-10-29T14:57:11.583277704+01:00
|
||||||
imports:
|
imports:
|
||||||
- name: github.com/abcum/cork
|
- name: github.com/abcum/cork
|
||||||
version: 177098ca294c7091ec158fd2a64a3422ddc7d166
|
version: 2d785aed8e7cc57a3b6741042a9b421a9d81fc13
|
||||||
- name: github.com/abcum/fibre
|
- name: github.com/abcum/fibre
|
||||||
version: cb521c4d2cdc231c3efa08aef9cc7c731741c2a8
|
version: cb521c4d2cdc231c3efa08aef9cc7c731741c2a8
|
||||||
subpackages:
|
subpackages:
|
||||||
|
|
57
sql/ast.go
57
sql/ast.go
|
@ -15,7 +15,6 @@
|
||||||
package sql
|
package sql
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -325,38 +324,18 @@ type Any struct{}
|
||||||
// Asc represents the ASC expression.
|
// Asc represents the ASC expression.
|
||||||
type Asc struct{}
|
type Asc struct{}
|
||||||
|
|
||||||
func (this Asc) MarshalText() (data []byte, err error) {
|
|
||||||
return []byte("~ASC~"), err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Desc represents the DESC expression.
|
// Desc represents the DESC expression.
|
||||||
type Desc struct{}
|
type Desc struct{}
|
||||||
|
|
||||||
func (this Desc) MarshalText() (data []byte, err error) {
|
|
||||||
return []byte("~DESC~"), err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Null represents a null expression.
|
// Null represents a null expression.
|
||||||
type Null struct{}
|
type Null struct{}
|
||||||
|
|
||||||
func (this Null) MarshalText() (data []byte, err error) {
|
|
||||||
return []byte("~NULL~"), err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Void represents an expression which is not set.
|
// Void represents an expression which is not set.
|
||||||
type Void struct{}
|
type Void struct{}
|
||||||
|
|
||||||
func (this Void) MarshalText() (data []byte, err error) {
|
|
||||||
return []byte("~VOID~"), err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Empty represents an expression which is null or "".
|
// Empty represents an expression which is null or "".
|
||||||
type Empty struct{}
|
type Empty struct{}
|
||||||
|
|
||||||
func (this Empty) MarshalText() (data []byte, err error) {
|
|
||||||
return []byte("~EMPTY~"), err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Field represents a SELECT AS clause.
|
// Field represents a SELECT AS clause.
|
||||||
type Field struct {
|
type Field struct {
|
||||||
Expr Expr
|
Expr Expr
|
||||||
|
@ -449,14 +428,6 @@ type Ident struct {
|
||||||
ID string
|
ID string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this Ident) String() string {
|
|
||||||
return this.ID
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this Ident) MarshalText() (data []byte, err error) {
|
|
||||||
return []byte("ID:" + this.ID), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewIdent(ID string) *Ident {
|
func NewIdent(ID string) *Ident {
|
||||||
return &Ident{ID}
|
return &Ident{ID}
|
||||||
}
|
}
|
||||||
|
@ -470,14 +441,6 @@ type Param struct {
|
||||||
ID string
|
ID string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this Param) String() string {
|
|
||||||
return this.ID
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this Param) MarshalText() (data []byte, err error) {
|
|
||||||
return []byte("ID:" + this.ID), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewParam(ID string) *Param {
|
func NewParam(ID string) *Param {
|
||||||
return &Param{ID}
|
return &Param{ID}
|
||||||
}
|
}
|
||||||
|
@ -491,14 +454,6 @@ type Table struct {
|
||||||
TB string
|
TB string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this Table) String() string {
|
|
||||||
return this.TB
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this Table) MarshalText() (data []byte, err error) {
|
|
||||||
return []byte("TB:" + this.TB), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewTable(TB string) *Table {
|
func NewTable(TB string) *Table {
|
||||||
return &Table{TB}
|
return &Table{TB}
|
||||||
}
|
}
|
||||||
|
@ -513,18 +468,6 @@ type Thing struct {
|
||||||
ID interface{}
|
ID interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this Thing) Bytes() []byte {
|
|
||||||
return []byte(this.String())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this Thing) String() string {
|
|
||||||
return fmt.Sprintf("@%s:%v", this.TB, this.ID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this Thing) MarshalText() (data []byte, err error) {
|
|
||||||
return []byte(this.String()), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewThing(TB interface{}, ID interface{}) *Thing {
|
func NewThing(TB interface{}, ID interface{}) *Thing {
|
||||||
if str, ok := ID.(string); ok {
|
if str, ok := ID.(string); ok {
|
||||||
if cnv, err := strconv.ParseFloat(str, 64); err == nil {
|
if cnv, err := strconv.ParseFloat(str, 64); err == nil {
|
||||||
|
|
1331
sql/cork.go
Normal file
1331
sql/cork.go
Normal file
File diff suppressed because it is too large
Load diff
|
@ -15,7 +15,7 @@
|
||||||
package sql
|
package sql
|
||||||
|
|
||||||
// Token defines a lexical token
|
// Token defines a lexical token
|
||||||
type Token int
|
type Token int16
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
||||||
|
@ -414,8 +414,6 @@ func (tok Token) String() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tok Token) MarshalText() (data []byte, err error) {
|
|
||||||
return []byte(tok.String()), err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tok Token) isLiteral() bool { return tok > literalsBeg && tok < literalsEnd }
|
func (tok Token) isLiteral() bool { return tok > literalsBeg && tok < literalsEnd }
|
||||||
|
|
Loading…
Reference in a new issue