Simplify and improve internal SQL AST structures
This commit is contained in:
parent
c7ae796275
commit
a3787ad274
30 changed files with 9239 additions and 5987 deletions
|
@ -51,7 +51,7 @@ func (e *executor) executeCreate(ctx context.Context, stm *sql.CreateStatement)
|
||||||
i.processThing(ctx, key)
|
i.processThing(ctx, key)
|
||||||
|
|
||||||
case *sql.Ident:
|
case *sql.Ident:
|
||||||
key := &keys.Thing{KV: stm.KV, NS: stm.NS, DB: stm.DB, TB: what.ID, ID: guid.New().String()}
|
key := &keys.Thing{KV: stm.KV, NS: stm.NS, DB: stm.DB, TB: what.VA, ID: guid.New().String()}
|
||||||
i.processThing(ctx, key)
|
i.processThing(ctx, key)
|
||||||
|
|
||||||
case *sql.Thing:
|
case *sql.Thing:
|
||||||
|
|
94
db/db.gen.go
94
db/db.gen.go
|
@ -11,23 +11,23 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// ----- content types ----
|
// ----- content types ----
|
||||||
codecSelferCcUTF89003 = 1
|
codecSelferCcUTF84219 = 1
|
||||||
codecSelferCcRAW9003 = 0
|
codecSelferCcRAW4219 = 0
|
||||||
// ----- value types used ----
|
// ----- value types used ----
|
||||||
codecSelferValueTypeArray9003 = 10
|
codecSelferValueTypeArray4219 = 10
|
||||||
codecSelferValueTypeMap9003 = 9
|
codecSelferValueTypeMap4219 = 9
|
||||||
codecSelferValueTypeString9003 = 6
|
codecSelferValueTypeString4219 = 6
|
||||||
codecSelferValueTypeInt9003 = 2
|
codecSelferValueTypeInt4219 = 2
|
||||||
codecSelferValueTypeUint9003 = 3
|
codecSelferValueTypeUint4219 = 3
|
||||||
codecSelferValueTypeFloat9003 = 4
|
codecSelferValueTypeFloat4219 = 4
|
||||||
codecSelferBitsize9003 = uint8(32 << (^uint(0) >> 63))
|
codecSelferBitsize4219 = uint8(32 << (^uint(0) >> 63))
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
errCodecSelferOnlyMapOrArrayEncodeToStruct9003 = errors.New(`only encoded map or array can be decoded into a struct`)
|
errCodecSelferOnlyMapOrArrayEncodeToStruct4219 = errors.New(`only encoded map or array can be decoded into a struct`)
|
||||||
)
|
)
|
||||||
|
|
||||||
type codecSelfer9003 struct{}
|
type codecSelfer4219 struct{}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if codec1978.GenVersion != 8 {
|
if codec1978.GenVersion != 8 {
|
||||||
|
@ -39,7 +39,7 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Response) CodecEncodeSelf(e *codec1978.Encoder) {
|
func (x *Response) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||||
var h codecSelfer9003
|
var h codecSelfer4219
|
||||||
z, r := codec1978.GenHelperEncoder(e)
|
z, r := codec1978.GenHelperEncoder(e)
|
||||||
_, _, _ = h, z, r
|
_, _, _ = h, z, r
|
||||||
if x == nil {
|
if x == nil {
|
||||||
|
@ -77,19 +77,19 @@ func (x *Response) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||||
if yyq2[0] {
|
if yyq2[0] {
|
||||||
if false {
|
if false {
|
||||||
} else {
|
} else {
|
||||||
r.EncodeString(codecSelferCcUTF89003, string(x.Time))
|
r.EncodeString(codecSelferCcUTF84219, string(x.Time))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
r.EncodeString(codecSelferCcUTF89003, "")
|
r.EncodeString(codecSelferCcUTF84219, "")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if yyq2[0] {
|
if yyq2[0] {
|
||||||
r.WriteMapElemKey()
|
r.WriteMapElemKey()
|
||||||
r.EncodeString(codecSelferCcUTF89003, `time`)
|
r.EncodeString(codecSelferCcUTF84219, `time`)
|
||||||
r.WriteMapElemValue()
|
r.WriteMapElemValue()
|
||||||
if false {
|
if false {
|
||||||
} else {
|
} else {
|
||||||
r.EncodeString(codecSelferCcUTF89003, string(x.Time))
|
r.EncodeString(codecSelferCcUTF84219, string(x.Time))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,19 +98,19 @@ func (x *Response) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||||
if yyq2[1] {
|
if yyq2[1] {
|
||||||
if false {
|
if false {
|
||||||
} else {
|
} else {
|
||||||
r.EncodeString(codecSelferCcUTF89003, string(x.Status))
|
r.EncodeString(codecSelferCcUTF84219, string(x.Status))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
r.EncodeString(codecSelferCcUTF89003, "")
|
r.EncodeString(codecSelferCcUTF84219, "")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if yyq2[1] {
|
if yyq2[1] {
|
||||||
r.WriteMapElemKey()
|
r.WriteMapElemKey()
|
||||||
r.EncodeString(codecSelferCcUTF89003, `status`)
|
r.EncodeString(codecSelferCcUTF84219, `status`)
|
||||||
r.WriteMapElemValue()
|
r.WriteMapElemValue()
|
||||||
if false {
|
if false {
|
||||||
} else {
|
} else {
|
||||||
r.EncodeString(codecSelferCcUTF89003, string(x.Status))
|
r.EncodeString(codecSelferCcUTF84219, string(x.Status))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,19 +119,19 @@ func (x *Response) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||||
if yyq2[2] {
|
if yyq2[2] {
|
||||||
if false {
|
if false {
|
||||||
} else {
|
} else {
|
||||||
r.EncodeString(codecSelferCcUTF89003, string(x.Detail))
|
r.EncodeString(codecSelferCcUTF84219, string(x.Detail))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
r.EncodeString(codecSelferCcUTF89003, "")
|
r.EncodeString(codecSelferCcUTF84219, "")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if yyq2[2] {
|
if yyq2[2] {
|
||||||
r.WriteMapElemKey()
|
r.WriteMapElemKey()
|
||||||
r.EncodeString(codecSelferCcUTF89003, `detail`)
|
r.EncodeString(codecSelferCcUTF84219, `detail`)
|
||||||
r.WriteMapElemValue()
|
r.WriteMapElemValue()
|
||||||
if false {
|
if false {
|
||||||
} else {
|
} else {
|
||||||
r.EncodeString(codecSelferCcUTF89003, string(x.Detail))
|
r.EncodeString(codecSelferCcUTF84219, string(x.Detail))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ func (x *Response) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||||
} else {
|
} else {
|
||||||
if yyq2[3] {
|
if yyq2[3] {
|
||||||
r.WriteMapElemKey()
|
r.WriteMapElemKey()
|
||||||
r.EncodeString(codecSelferCcUTF89003, `result`)
|
r.EncodeString(codecSelferCcUTF84219, `result`)
|
||||||
r.WriteMapElemValue()
|
r.WriteMapElemValue()
|
||||||
if x.Result == nil {
|
if x.Result == nil {
|
||||||
r.EncodeNil()
|
r.EncodeNil()
|
||||||
|
@ -174,7 +174,7 @@ func (x *Response) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Response) CodecDecodeSelf(d *codec1978.Decoder) {
|
func (x *Response) CodecDecodeSelf(d *codec1978.Decoder) {
|
||||||
var h codecSelfer9003
|
var h codecSelfer4219
|
||||||
z, r := codec1978.GenHelperDecoder(d)
|
z, r := codec1978.GenHelperDecoder(d)
|
||||||
_, _, _ = h, z, r
|
_, _, _ = h, z, r
|
||||||
if false {
|
if false {
|
||||||
|
@ -182,14 +182,14 @@ func (x *Response) CodecDecodeSelf(d *codec1978.Decoder) {
|
||||||
z.DecExtension(x, yyxt1)
|
z.DecExtension(x, yyxt1)
|
||||||
} else {
|
} else {
|
||||||
yyct2 := r.ContainerType()
|
yyct2 := r.ContainerType()
|
||||||
if yyct2 == codecSelferValueTypeMap9003 {
|
if yyct2 == codecSelferValueTypeMap4219 {
|
||||||
yyl2 := r.ReadMapStart()
|
yyl2 := r.ReadMapStart()
|
||||||
if yyl2 == 0 {
|
if yyl2 == 0 {
|
||||||
r.ReadMapEnd()
|
r.ReadMapEnd()
|
||||||
} else {
|
} else {
|
||||||
x.codecDecodeSelfFromMap(yyl2, d)
|
x.codecDecodeSelfFromMap(yyl2, d)
|
||||||
}
|
}
|
||||||
} else if yyct2 == codecSelferValueTypeArray9003 {
|
} else if yyct2 == codecSelferValueTypeArray4219 {
|
||||||
yyl2 := r.ReadArrayStart()
|
yyl2 := r.ReadArrayStart()
|
||||||
if yyl2 == 0 {
|
if yyl2 == 0 {
|
||||||
r.ReadArrayEnd()
|
r.ReadArrayEnd()
|
||||||
|
@ -197,13 +197,13 @@ func (x *Response) CodecDecodeSelf(d *codec1978.Decoder) {
|
||||||
x.codecDecodeSelfFromArray(yyl2, d)
|
x.codecDecodeSelfFromArray(yyl2, d)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
panic(errCodecSelferOnlyMapOrArrayEncodeToStruct9003)
|
panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4219)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Response) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
|
func (x *Response) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
|
||||||
var h codecSelfer9003
|
var h codecSelfer4219
|
||||||
z, r := codec1978.GenHelperDecoder(d)
|
z, r := codec1978.GenHelperDecoder(d)
|
||||||
_, _, _ = h, z, r
|
_, _, _ = h, z, r
|
||||||
var yyhl3 bool = l >= 0
|
var yyhl3 bool = l >= 0
|
||||||
|
@ -256,7 +256,7 @@ func (x *Response) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Response) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
|
func (x *Response) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
|
||||||
var h codecSelfer9003
|
var h codecSelfer4219
|
||||||
z, r := codec1978.GenHelperDecoder(d)
|
z, r := codec1978.GenHelperDecoder(d)
|
||||||
_, _, _ = h, z, r
|
_, _, _ = h, z, r
|
||||||
var yyj9 int
|
var yyj9 int
|
||||||
|
@ -346,7 +346,7 @@ func (x *Response) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Dispatch) CodecEncodeSelf(e *codec1978.Encoder) {
|
func (x *Dispatch) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||||
var h codecSelfer9003
|
var h codecSelfer4219
|
||||||
z, r := codec1978.GenHelperEncoder(e)
|
z, r := codec1978.GenHelperEncoder(e)
|
||||||
_, _, _ = h, z, r
|
_, _, _ = h, z, r
|
||||||
if x == nil {
|
if x == nil {
|
||||||
|
@ -383,19 +383,19 @@ func (x *Dispatch) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||||
if yyq2[0] {
|
if yyq2[0] {
|
||||||
if false {
|
if false {
|
||||||
} else {
|
} else {
|
||||||
r.EncodeString(codecSelferCcUTF89003, string(x.Query))
|
r.EncodeString(codecSelferCcUTF84219, string(x.Query))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
r.EncodeString(codecSelferCcUTF89003, "")
|
r.EncodeString(codecSelferCcUTF84219, "")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if yyq2[0] {
|
if yyq2[0] {
|
||||||
r.WriteMapElemKey()
|
r.WriteMapElemKey()
|
||||||
r.EncodeString(codecSelferCcUTF89003, `query`)
|
r.EncodeString(codecSelferCcUTF84219, `query`)
|
||||||
r.WriteMapElemValue()
|
r.WriteMapElemValue()
|
||||||
if false {
|
if false {
|
||||||
} else {
|
} else {
|
||||||
r.EncodeString(codecSelferCcUTF89003, string(x.Query))
|
r.EncodeString(codecSelferCcUTF84219, string(x.Query))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -404,19 +404,19 @@ func (x *Dispatch) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||||
if yyq2[1] {
|
if yyq2[1] {
|
||||||
if false {
|
if false {
|
||||||
} else {
|
} else {
|
||||||
r.EncodeString(codecSelferCcUTF89003, string(x.Action))
|
r.EncodeString(codecSelferCcUTF84219, string(x.Action))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
r.EncodeString(codecSelferCcUTF89003, "")
|
r.EncodeString(codecSelferCcUTF84219, "")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if yyq2[1] {
|
if yyq2[1] {
|
||||||
r.WriteMapElemKey()
|
r.WriteMapElemKey()
|
||||||
r.EncodeString(codecSelferCcUTF89003, `action`)
|
r.EncodeString(codecSelferCcUTF84219, `action`)
|
||||||
r.WriteMapElemValue()
|
r.WriteMapElemValue()
|
||||||
if false {
|
if false {
|
||||||
} else {
|
} else {
|
||||||
r.EncodeString(codecSelferCcUTF89003, string(x.Action))
|
r.EncodeString(codecSelferCcUTF84219, string(x.Action))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -437,7 +437,7 @@ func (x *Dispatch) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||||
} else {
|
} else {
|
||||||
if yyq2[2] {
|
if yyq2[2] {
|
||||||
r.WriteMapElemKey()
|
r.WriteMapElemKey()
|
||||||
r.EncodeString(codecSelferCcUTF89003, `result`)
|
r.EncodeString(codecSelferCcUTF84219, `result`)
|
||||||
r.WriteMapElemValue()
|
r.WriteMapElemValue()
|
||||||
if x.Result == nil {
|
if x.Result == nil {
|
||||||
r.EncodeNil()
|
r.EncodeNil()
|
||||||
|
@ -459,7 +459,7 @@ func (x *Dispatch) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Dispatch) CodecDecodeSelf(d *codec1978.Decoder) {
|
func (x *Dispatch) CodecDecodeSelf(d *codec1978.Decoder) {
|
||||||
var h codecSelfer9003
|
var h codecSelfer4219
|
||||||
z, r := codec1978.GenHelperDecoder(d)
|
z, r := codec1978.GenHelperDecoder(d)
|
||||||
_, _, _ = h, z, r
|
_, _, _ = h, z, r
|
||||||
if false {
|
if false {
|
||||||
|
@ -467,14 +467,14 @@ func (x *Dispatch) CodecDecodeSelf(d *codec1978.Decoder) {
|
||||||
z.DecExtension(x, yyxt1)
|
z.DecExtension(x, yyxt1)
|
||||||
} else {
|
} else {
|
||||||
yyct2 := r.ContainerType()
|
yyct2 := r.ContainerType()
|
||||||
if yyct2 == codecSelferValueTypeMap9003 {
|
if yyct2 == codecSelferValueTypeMap4219 {
|
||||||
yyl2 := r.ReadMapStart()
|
yyl2 := r.ReadMapStart()
|
||||||
if yyl2 == 0 {
|
if yyl2 == 0 {
|
||||||
r.ReadMapEnd()
|
r.ReadMapEnd()
|
||||||
} else {
|
} else {
|
||||||
x.codecDecodeSelfFromMap(yyl2, d)
|
x.codecDecodeSelfFromMap(yyl2, d)
|
||||||
}
|
}
|
||||||
} else if yyct2 == codecSelferValueTypeArray9003 {
|
} else if yyct2 == codecSelferValueTypeArray4219 {
|
||||||
yyl2 := r.ReadArrayStart()
|
yyl2 := r.ReadArrayStart()
|
||||||
if yyl2 == 0 {
|
if yyl2 == 0 {
|
||||||
r.ReadArrayEnd()
|
r.ReadArrayEnd()
|
||||||
|
@ -482,13 +482,13 @@ func (x *Dispatch) CodecDecodeSelf(d *codec1978.Decoder) {
|
||||||
x.codecDecodeSelfFromArray(yyl2, d)
|
x.codecDecodeSelfFromArray(yyl2, d)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
panic(errCodecSelferOnlyMapOrArrayEncodeToStruct9003)
|
panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4219)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Dispatch) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
|
func (x *Dispatch) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
|
||||||
var h codecSelfer9003
|
var h codecSelfer4219
|
||||||
z, r := codec1978.GenHelperDecoder(d)
|
z, r := codec1978.GenHelperDecoder(d)
|
||||||
_, _, _ = h, z, r
|
_, _, _ = h, z, r
|
||||||
var yyhl3 bool = l >= 0
|
var yyhl3 bool = l >= 0
|
||||||
|
@ -535,7 +535,7 @@ func (x *Dispatch) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Dispatch) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
|
func (x *Dispatch) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
|
||||||
var h codecSelfer9003
|
var h codecSelfer4219
|
||||||
z, r := codec1978.GenHelperDecoder(d)
|
z, r := codec1978.GenHelperDecoder(d)
|
||||||
_, _, _ = h, z, r
|
_, _, _ = h, z, r
|
||||||
var yyj8 int
|
var yyj8 int
|
||||||
|
|
22
db/define.go
22
db/define.go
|
@ -27,7 +27,7 @@ import (
|
||||||
func (e *executor) executeDefineNamespace(ctx context.Context, ast *sql.DefineNamespaceStatement) (out []interface{}, err error) {
|
func (e *executor) executeDefineNamespace(ctx context.Context, ast *sql.DefineNamespaceStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
// Save the namespace definition
|
// Save the namespace definition
|
||||||
nkey := &keys.NS{KV: ast.KV, NS: ast.Name.ID}
|
nkey := &keys.NS{KV: ast.KV, NS: ast.Name.VA}
|
||||||
_, err = e.dbo.Put(ctx, 0, nkey.Encode(), ast.Encode())
|
_, err = e.dbo.Put(ctx, 0, nkey.Encode(), ast.Encode())
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -39,7 +39,7 @@ func (e *executor) executeDefineDatabase(ctx context.Context, ast *sql.DefineDat
|
||||||
e.dbo.AddNS(ctx, ast.NS)
|
e.dbo.AddNS(ctx, ast.NS)
|
||||||
|
|
||||||
// Save the database definition
|
// Save the database definition
|
||||||
dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.Name.ID}
|
dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.Name.VA}
|
||||||
_, err = e.dbo.Put(ctx, 0, dkey.Encode(), ast.Encode())
|
_, err = e.dbo.Put(ctx, 0, dkey.Encode(), ast.Encode())
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -58,7 +58,7 @@ func (e *executor) executeDefineLogin(ctx context.Context, ast *sql.DefineLoginS
|
||||||
e.dbo.AddNS(ctx, ast.NS)
|
e.dbo.AddNS(ctx, ast.NS)
|
||||||
|
|
||||||
// Save the login definition
|
// Save the login definition
|
||||||
ukey := &keys.NU{KV: ast.KV, NS: ast.NS, US: ast.User.ID}
|
ukey := &keys.NU{KV: ast.KV, NS: ast.NS, US: ast.User.VA}
|
||||||
_, err = e.dbo.Put(ctx, 0, ukey.Encode(), ast.Encode())
|
_, err = e.dbo.Put(ctx, 0, ukey.Encode(), ast.Encode())
|
||||||
|
|
||||||
case sql.DATABASE:
|
case sql.DATABASE:
|
||||||
|
@ -66,7 +66,7 @@ func (e *executor) executeDefineLogin(ctx context.Context, ast *sql.DefineLoginS
|
||||||
e.dbo.AddDB(ctx, ast.NS, ast.DB)
|
e.dbo.AddDB(ctx, ast.NS, ast.DB)
|
||||||
|
|
||||||
// Save the login definition
|
// Save the login definition
|
||||||
ukey := &keys.DU{KV: ast.KV, NS: ast.NS, DB: ast.DB, US: ast.User.ID}
|
ukey := &keys.DU{KV: ast.KV, NS: ast.NS, DB: ast.DB, US: ast.User.VA}
|
||||||
_, err = e.dbo.Put(ctx, 0, ukey.Encode(), ast.Encode())
|
_, err = e.dbo.Put(ctx, 0, ukey.Encode(), ast.Encode())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ func (e *executor) executeDefineToken(ctx context.Context, ast *sql.DefineTokenS
|
||||||
e.dbo.AddNS(ctx, ast.NS)
|
e.dbo.AddNS(ctx, ast.NS)
|
||||||
|
|
||||||
// Save the token definition
|
// Save the token definition
|
||||||
tkey := &keys.NT{KV: ast.KV, NS: ast.NS, TK: ast.Name.ID}
|
tkey := &keys.NT{KV: ast.KV, NS: ast.NS, TK: ast.Name.VA}
|
||||||
_, err = e.dbo.Put(ctx, 0, tkey.Encode(), ast.Encode())
|
_, err = e.dbo.Put(ctx, 0, tkey.Encode(), ast.Encode())
|
||||||
|
|
||||||
case sql.DATABASE:
|
case sql.DATABASE:
|
||||||
|
@ -91,7 +91,7 @@ func (e *executor) executeDefineToken(ctx context.Context, ast *sql.DefineTokenS
|
||||||
e.dbo.AddDB(ctx, ast.NS, ast.DB)
|
e.dbo.AddDB(ctx, ast.NS, ast.DB)
|
||||||
|
|
||||||
// Save the token definition
|
// Save the token definition
|
||||||
tkey := &keys.DT{KV: ast.KV, NS: ast.NS, DB: ast.DB, TK: ast.Name.ID}
|
tkey := &keys.DT{KV: ast.KV, NS: ast.NS, DB: ast.DB, TK: ast.Name.VA}
|
||||||
_, err = e.dbo.Put(ctx, 0, tkey.Encode(), ast.Encode())
|
_, err = e.dbo.Put(ctx, 0, tkey.Encode(), ast.Encode())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ func (e *executor) executeDefineScope(ctx context.Context, ast *sql.DefineScopeS
|
||||||
e.dbo.AddDB(ctx, ast.NS, ast.DB)
|
e.dbo.AddDB(ctx, ast.NS, ast.DB)
|
||||||
|
|
||||||
// Remove the scope definition
|
// Remove the scope definition
|
||||||
skey := &keys.SC{KV: ast.KV, NS: ast.NS, DB: ast.DB, SC: ast.Name.ID}
|
skey := &keys.SC{KV: ast.KV, NS: ast.NS, DB: ast.DB, SC: ast.Name.VA}
|
||||||
_, err = e.dbo.Put(ctx, 0, skey.Encode(), ast.Encode())
|
_, err = e.dbo.Put(ctx, 0, skey.Encode(), ast.Encode())
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -121,7 +121,7 @@ func (e *executor) executeDefineEvent(ctx context.Context, ast *sql.DefineEventS
|
||||||
e.dbo.AddTB(ctx, ast.NS, ast.DB, TB.TB)
|
e.dbo.AddTB(ctx, ast.NS, ast.DB, TB.TB)
|
||||||
|
|
||||||
// Remove the event definition
|
// Remove the event definition
|
||||||
ekey := &keys.EV{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB.TB, EV: ast.Name.ID}
|
ekey := &keys.EV{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB.TB, EV: ast.Name.VA}
|
||||||
if _, err = e.dbo.Put(ctx, 0, ekey.Encode(), ast.Encode()); err != nil {
|
if _, err = e.dbo.Put(ctx, 0, ekey.Encode(), ast.Encode()); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ func (e *executor) executeDefineField(ctx context.Context, ast *sql.DefineFieldS
|
||||||
e.dbo.AddTB(ctx, ast.NS, ast.DB, TB.TB)
|
e.dbo.AddTB(ctx, ast.NS, ast.DB, TB.TB)
|
||||||
|
|
||||||
// Save the field definition
|
// Save the field definition
|
||||||
fkey := &keys.FD{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB.TB, FD: ast.Name.ID}
|
fkey := &keys.FD{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB.TB, FD: ast.Name.VA}
|
||||||
if _, err = e.dbo.Put(ctx, 0, fkey.Encode(), ast.Encode()); err != nil {
|
if _, err = e.dbo.Put(ctx, 0, fkey.Encode(), ast.Encode()); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -157,13 +157,13 @@ func (e *executor) executeDefineIndex(ctx context.Context, ast *sql.DefineIndexS
|
||||||
e.dbo.AddTB(ctx, ast.NS, ast.DB, TB.TB)
|
e.dbo.AddTB(ctx, ast.NS, ast.DB, TB.TB)
|
||||||
|
|
||||||
// Save the index definition
|
// Save the index definition
|
||||||
ikey := &keys.IX{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB.TB, IX: ast.Name.ID}
|
ikey := &keys.IX{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB.TB, IX: ast.Name.VA}
|
||||||
if _, err = e.dbo.Put(ctx, 0, ikey.Encode(), ast.Encode()); err != nil {
|
if _, err = e.dbo.Put(ctx, 0, ikey.Encode(), ast.Encode()); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the index resource data
|
// Remove the index resource data
|
||||||
dkey := &keys.Index{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB.TB, IX: ast.Name.ID, FD: keys.Ignore}
|
dkey := &keys.Index{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB.TB, IX: ast.Name.VA, FD: keys.Ignore}
|
||||||
if _, err = e.dbo.ClrP(ctx, dkey.Encode(), 0); err != nil {
|
if _, err = e.dbo.ClrP(ctx, dkey.Encode(), 0); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ func (e *executor) executeDelete(ctx context.Context, stm *sql.DeleteStatement)
|
||||||
i.processTable(ctx, key)
|
i.processTable(ctx, key)
|
||||||
|
|
||||||
case *sql.Ident:
|
case *sql.Ident:
|
||||||
key := &keys.Table{KV: stm.KV, NS: stm.NS, DB: stm.DB, TB: what.ID}
|
key := &keys.Table{KV: stm.KV, NS: stm.NS, DB: stm.DB, TB: what.VA}
|
||||||
i.processTable(ctx, key)
|
i.processTable(ctx, key)
|
||||||
|
|
||||||
case *sql.Thing:
|
case *sql.Thing:
|
||||||
|
|
|
@ -32,7 +32,6 @@ type document struct {
|
||||||
ns string
|
ns string
|
||||||
db string
|
db string
|
||||||
tb string
|
tb string
|
||||||
md map[string]interface{}
|
|
||||||
id *sql.Thing
|
id *sql.Thing
|
||||||
key *keys.Thing
|
key *keys.Thing
|
||||||
val kvs.KV
|
val kvs.KV
|
||||||
|
@ -449,11 +448,11 @@ func (d *document) storeIndex(ctx context.Context) (err error) {
|
||||||
|
|
||||||
if ix.Uniq == true {
|
if ix.Uniq == true {
|
||||||
for _, v := range del {
|
for _, v := range del {
|
||||||
didx := &keys.Index{KV: d.key.KV, NS: d.key.NS, DB: d.key.DB, TB: d.key.TB, IX: ix.Name.ID, FD: v}
|
didx := &keys.Index{KV: d.key.KV, NS: d.key.NS, DB: d.key.DB, TB: d.key.TB, IX: ix.Name.VA, FD: v}
|
||||||
d.i.e.dbo.DelC(ctx, d.i.e.time, didx.Encode(), d.id.Bytes())
|
d.i.e.dbo.DelC(ctx, d.i.e.time, didx.Encode(), d.id.Bytes())
|
||||||
}
|
}
|
||||||
for _, v := range add {
|
for _, v := range add {
|
||||||
aidx := &keys.Index{KV: d.key.KV, NS: d.key.NS, DB: d.key.DB, TB: d.key.TB, IX: ix.Name.ID, FD: v}
|
aidx := &keys.Index{KV: d.key.KV, NS: d.key.NS, DB: d.key.DB, TB: d.key.TB, IX: ix.Name.VA, FD: v}
|
||||||
if _, err = d.i.e.dbo.PutC(ctx, 0, aidx.Encode(), d.id.Bytes(), nil); err != nil {
|
if _, err = d.i.e.dbo.PutC(ctx, 0, aidx.Encode(), d.id.Bytes(), nil); err != nil {
|
||||||
return &IndexError{tb: d.key.TB, name: ix.Name, cols: ix.Cols, vals: v}
|
return &IndexError{tb: d.key.TB, name: ix.Name, cols: ix.Cols, vals: v}
|
||||||
}
|
}
|
||||||
|
@ -462,11 +461,11 @@ func (d *document) storeIndex(ctx context.Context) (err error) {
|
||||||
|
|
||||||
if ix.Uniq == false {
|
if ix.Uniq == false {
|
||||||
for _, v := range del {
|
for _, v := range del {
|
||||||
didx := &keys.Point{KV: d.key.KV, NS: d.key.NS, DB: d.key.DB, TB: d.key.TB, IX: ix.Name.ID, FD: v, ID: d.key.ID}
|
didx := &keys.Point{KV: d.key.KV, NS: d.key.NS, DB: d.key.DB, TB: d.key.TB, IX: ix.Name.VA, FD: v, ID: d.key.ID}
|
||||||
d.i.e.dbo.DelC(ctx, d.i.e.time, didx.Encode(), d.id.Bytes())
|
d.i.e.dbo.DelC(ctx, d.i.e.time, didx.Encode(), d.id.Bytes())
|
||||||
}
|
}
|
||||||
for _, v := range add {
|
for _, v := range add {
|
||||||
aidx := &keys.Point{KV: d.key.KV, NS: d.key.NS, DB: d.key.DB, TB: d.key.TB, IX: ix.Name.ID, FD: v, ID: d.key.ID}
|
aidx := &keys.Point{KV: d.key.KV, NS: d.key.NS, DB: d.key.DB, TB: d.key.TB, IX: ix.Name.VA, FD: v, ID: d.key.ID}
|
||||||
if _, err = d.i.e.dbo.PutC(ctx, 0, aidx.Encode(), d.id.Bytes(), nil); err != nil {
|
if _, err = d.i.e.dbo.PutC(ctx, 0, aidx.Encode(), d.id.Bytes(), nil); err != nil {
|
||||||
return &IndexError{tb: d.key.TB, name: ix.Name, cols: ix.Cols, vals: v}
|
return &IndexError{tb: d.key.TB, name: ix.Name, cols: ix.Cols, vals: v}
|
||||||
}
|
}
|
||||||
|
@ -515,14 +514,14 @@ func (d *document) purgeIndex(ctx context.Context) (err error) {
|
||||||
|
|
||||||
if ix.Uniq == true {
|
if ix.Uniq == true {
|
||||||
for _, v := range del {
|
for _, v := range del {
|
||||||
key := &keys.Index{KV: d.key.KV, NS: d.key.NS, DB: d.key.DB, TB: d.key.TB, IX: ix.Name.ID, FD: v}
|
key := &keys.Index{KV: d.key.KV, NS: d.key.NS, DB: d.key.DB, TB: d.key.TB, IX: ix.Name.VA, FD: v}
|
||||||
d.i.e.dbo.DelC(ctx, 0, key.Encode(), d.id.Bytes())
|
d.i.e.dbo.DelC(ctx, 0, key.Encode(), d.id.Bytes())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ix.Uniq == false {
|
if ix.Uniq == false {
|
||||||
for _, v := range del {
|
for _, v := range del {
|
||||||
key := &keys.Point{KV: d.key.KV, NS: d.key.NS, DB: d.key.DB, TB: d.key.TB, IX: ix.Name.ID, FD: v, ID: d.key.ID}
|
key := &keys.Point{KV: d.key.KV, NS: d.key.NS, DB: d.key.DB, TB: d.key.TB, IX: ix.Name.VA, FD: v, ID: d.key.ID}
|
||||||
d.i.e.dbo.DelC(ctx, 0, key.Encode(), d.id.Bytes())
|
d.i.e.dbo.DelC(ctx, 0, key.Encode(), d.id.Bytes())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
46
db/fetch.go
46
db/fetch.go
|
@ -42,30 +42,14 @@ func (e *executor) fetch(ctx context.Context, val interface{}, doc *data.Doc) (o
|
||||||
return val, nil
|
return val, nil
|
||||||
case *sql.Null:
|
case *sql.Null:
|
||||||
return nil, nil
|
return nil, nil
|
||||||
case *sql.Thing:
|
|
||||||
return val, nil
|
|
||||||
case *sql.Value:
|
case *sql.Value:
|
||||||
return val.ID, nil
|
return val.VA, nil
|
||||||
case int:
|
case int:
|
||||||
return float64(val), nil
|
return float64(val), nil
|
||||||
case int8:
|
|
||||||
return float64(val), nil
|
|
||||||
case int16:
|
|
||||||
return float64(val), nil
|
|
||||||
case int32:
|
|
||||||
return float64(val), nil
|
|
||||||
case int64:
|
case int64:
|
||||||
return float64(val), nil
|
return float64(val), nil
|
||||||
case uint:
|
case float64:
|
||||||
return float64(val), nil
|
return float64(val), nil
|
||||||
case uint16:
|
|
||||||
return float64(val), nil
|
|
||||||
case uint32:
|
|
||||||
return float64(val), nil
|
|
||||||
case uint64:
|
|
||||||
return float64(val), nil
|
|
||||||
case []byte:
|
|
||||||
return string(val), nil
|
|
||||||
case []interface{}:
|
case []interface{}:
|
||||||
return deep.Copy(val), nil
|
return deep.Copy(val), nil
|
||||||
case map[string]interface{}:
|
case map[string]interface{}:
|
||||||
|
@ -73,7 +57,7 @@ func (e *executor) fetch(ctx context.Context, val interface{}, doc *data.Doc) (o
|
||||||
|
|
||||||
case *sql.Regex:
|
case *sql.Regex:
|
||||||
|
|
||||||
return regexp.Compile(val.ID)
|
return regexp.Compile(val.VA)
|
||||||
|
|
||||||
case *sql.Ident:
|
case *sql.Ident:
|
||||||
|
|
||||||
|
@ -98,7 +82,7 @@ func (e *executor) fetch(ctx context.Context, val interface{}, doc *data.Doc) (o
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
res := doc.Fetch(fnc, val.ID).Data()
|
res := doc.Fetch(fnc, val.VA).Data()
|
||||||
|
|
||||||
return e.fetch(ctx, res, doc)
|
return e.fetch(ctx, res, doc)
|
||||||
|
|
||||||
|
@ -106,7 +90,7 @@ func (e *executor) fetch(ctx context.Context, val interface{}, doc *data.Doc) (o
|
||||||
|
|
||||||
case *sql.Param:
|
case *sql.Param:
|
||||||
|
|
||||||
if len(val.ID) > 0 {
|
if len(val.VA) > 0 {
|
||||||
|
|
||||||
for _, s := range paramSearchKeys {
|
for _, s := range paramSearchKeys {
|
||||||
|
|
||||||
|
@ -126,7 +110,7 @@ func (e *executor) fetch(ctx context.Context, val interface{}, doc *data.Doc) (o
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
res := obj.Fetch(fnc, val.ID).Data()
|
res := obj.Fetch(fnc, val.VA).Data()
|
||||||
|
|
||||||
if res != nil {
|
if res != nil {
|
||||||
return e.fetch(ctx, res, doc)
|
return e.fetch(ctx, res, doc)
|
||||||
|
@ -420,7 +404,7 @@ func (e *executor) fetchPerms(ctx context.Context, val sql.Expr, tb *sql.Ident)
|
||||||
|
|
||||||
if err != queryIdentFailed {
|
if err != queryIdentFailed {
|
||||||
if res, ok := res.(bool); ok && !res {
|
if res, ok := res.(bool); ok && !res {
|
||||||
return &PermsError{table: tb.ID}
|
return &PermsError{table: tb.VA}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -641,18 +625,18 @@ func binaryCheck(op sql.Token, l, r, lo, ro interface{}, d *data.Doc) interface{
|
||||||
switch r := ro.(type) {
|
switch r := ro.(type) {
|
||||||
case *sql.Ident:
|
case *sql.Ident:
|
||||||
if op == sql.EQ {
|
if op == sql.EQ {
|
||||||
return d.Exists(r.ID) == false
|
return d.Exists(r.VA) == false
|
||||||
} else if op == sql.NEQ {
|
} else if op == sql.NEQ {
|
||||||
return d.Exists(r.ID) == true
|
return d.Exists(r.VA) == true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case *sql.Null:
|
case *sql.Null:
|
||||||
switch r := ro.(type) {
|
switch r := ro.(type) {
|
||||||
case *sql.Ident:
|
case *sql.Ident:
|
||||||
if op == sql.EQ {
|
if op == sql.EQ {
|
||||||
return d.Exists(r.ID) == true && d.Get(r.ID).Data() == nil
|
return d.Exists(r.VA) == true && d.Get(r.VA).Data() == nil
|
||||||
} else if op == sql.NEQ {
|
} else if op == sql.NEQ {
|
||||||
return d.Exists(r.ID) == false || d.Get(r.ID).Data() != nil
|
return d.Exists(r.VA) == false || d.Get(r.VA).Data() != nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -662,18 +646,18 @@ func binaryCheck(op sql.Token, l, r, lo, ro interface{}, d *data.Doc) interface{
|
||||||
switch l := lo.(type) {
|
switch l := lo.(type) {
|
||||||
case *sql.Ident:
|
case *sql.Ident:
|
||||||
if op == sql.EQ {
|
if op == sql.EQ {
|
||||||
return d.Exists(l.ID) == false
|
return d.Exists(l.VA) == false
|
||||||
} else if op == sql.NEQ {
|
} else if op == sql.NEQ {
|
||||||
return d.Exists(l.ID) == true
|
return d.Exists(l.VA) == true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case *sql.Null:
|
case *sql.Null:
|
||||||
switch l := lo.(type) {
|
switch l := lo.(type) {
|
||||||
case *sql.Ident:
|
case *sql.Ident:
|
||||||
if op == sql.EQ {
|
if op == sql.EQ {
|
||||||
return d.Exists(l.ID) == true && d.Get(l.ID).Data() == nil
|
return d.Exists(l.VA) == true && d.Get(l.VA).Data() == nil
|
||||||
} else if op == sql.NEQ {
|
} else if op == sql.NEQ {
|
||||||
return d.Exists(l.ID) == false || d.Get(l.ID).Data() != nil
|
return d.Exists(l.VA) == false || d.Get(l.VA).Data() != nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
22
db/info.go
22
db/info.go
|
@ -57,17 +57,17 @@ func (e *executor) executeInfoNS(ctx context.Context, ast *sql.InfoStatement) (o
|
||||||
|
|
||||||
dbase := make(map[string]interface{})
|
dbase := make(map[string]interface{})
|
||||||
for _, v := range db {
|
for _, v := range db {
|
||||||
dbase[v.Name.ID] = v.String()
|
dbase[v.Name.VA] = v.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
token := make(map[string]interface{})
|
token := make(map[string]interface{})
|
||||||
for _, v := range nt {
|
for _, v := range nt {
|
||||||
token[v.Name.ID] = v.String()
|
token[v.Name.VA] = v.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
login := make(map[string]interface{})
|
login := make(map[string]interface{})
|
||||||
for _, v := range nu {
|
for _, v := range nu {
|
||||||
login[v.User.ID] = v.String()
|
login[v.User.VA] = v.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
res.Set(dbase, "database")
|
res.Set(dbase, "database")
|
||||||
|
@ -104,22 +104,22 @@ func (e *executor) executeInfoDB(ctx context.Context, ast *sql.InfoStatement) (o
|
||||||
|
|
||||||
table := make(map[string]interface{})
|
table := make(map[string]interface{})
|
||||||
for _, v := range tb {
|
for _, v := range tb {
|
||||||
table[v.Name.ID] = v.String()
|
table[v.Name.VA] = v.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
token := make(map[string]interface{})
|
token := make(map[string]interface{})
|
||||||
for _, v := range dt {
|
for _, v := range dt {
|
||||||
token[v.Name.ID] = v.String()
|
token[v.Name.VA] = v.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
login := make(map[string]interface{})
|
login := make(map[string]interface{})
|
||||||
for _, v := range du {
|
for _, v := range du {
|
||||||
login[v.User.ID] = v.String()
|
login[v.User.VA] = v.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
scope := make(map[string]interface{})
|
scope := make(map[string]interface{})
|
||||||
for _, v := range sc {
|
for _, v := range sc {
|
||||||
scope[v.Name.ID] = v.String()
|
scope[v.Name.VA] = v.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
res.Set(table, "table")
|
res.Set(table, "table")
|
||||||
|
@ -157,22 +157,22 @@ func (e *executor) executeInfoTB(ctx context.Context, ast *sql.InfoStatement) (o
|
||||||
|
|
||||||
event := make(map[string]interface{})
|
event := make(map[string]interface{})
|
||||||
for _, v := range ev {
|
for _, v := range ev {
|
||||||
event[v.Name.ID] = v.String()
|
event[v.Name.VA] = v.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
field := make(map[string]interface{})
|
field := make(map[string]interface{})
|
||||||
for _, v := range fd {
|
for _, v := range fd {
|
||||||
field[v.Name.ID] = v.String()
|
field[v.Name.VA] = v.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
index := make(map[string]interface{})
|
index := make(map[string]interface{})
|
||||||
for _, v := range ix {
|
for _, v := range ix {
|
||||||
index[v.Name.ID] = v.String()
|
index[v.Name.VA] = v.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
table := make(map[string]interface{})
|
table := make(map[string]interface{})
|
||||||
for _, v := range ft {
|
for _, v := range ft {
|
||||||
table[v.Name.ID] = v.String()
|
table[v.Name.VA] = v.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
res.Set(event, "event")
|
res.Set(event, "event")
|
||||||
|
|
|
@ -394,17 +394,17 @@ func (i *iterator) processPerms(ctx context.Context, nsv, dbv, tbv string) {
|
||||||
if tb.Lock && i.vir == false {
|
if tb.Lock && i.vir == false {
|
||||||
switch i.stm.(type) {
|
switch i.stm.(type) {
|
||||||
case *sql.CreateStatement:
|
case *sql.CreateStatement:
|
||||||
i.err = &TableError{table: tb.Name.ID}
|
i.err = &TableError{table: tb.Name.VA}
|
||||||
case *sql.UpdateStatement:
|
case *sql.UpdateStatement:
|
||||||
i.err = &TableError{table: tb.Name.ID}
|
i.err = &TableError{table: tb.Name.VA}
|
||||||
case *sql.DeleteStatement:
|
case *sql.DeleteStatement:
|
||||||
i.err = &TableError{table: tb.Name.ID}
|
i.err = &TableError{table: tb.Name.VA}
|
||||||
case *sql.RelateStatement:
|
case *sql.RelateStatement:
|
||||||
i.err = &TableError{table: tb.Name.ID}
|
i.err = &TableError{table: tb.Name.VA}
|
||||||
case *sql.InsertStatement:
|
case *sql.InsertStatement:
|
||||||
i.err = &TableError{table: tb.Name.ID}
|
i.err = &TableError{table: tb.Name.VA}
|
||||||
case *sql.UpsertStatement:
|
case *sql.UpsertStatement:
|
||||||
i.err = &TableError{table: tb.Name.ID}
|
i.err = &TableError{table: tb.Name.VA}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,17 +464,17 @@ func (i *iterator) processPerms(ctx context.Context, nsv, dbv, tbv string) {
|
||||||
if tb.Lock && i.vir == false {
|
if tb.Lock && i.vir == false {
|
||||||
switch i.stm.(type) {
|
switch i.stm.(type) {
|
||||||
case *sql.CreateStatement:
|
case *sql.CreateStatement:
|
||||||
i.err = &TableError{table: tb.Name.ID}
|
i.err = &TableError{table: tb.Name.VA}
|
||||||
case *sql.UpdateStatement:
|
case *sql.UpdateStatement:
|
||||||
i.err = &TableError{table: tb.Name.ID}
|
i.err = &TableError{table: tb.Name.VA}
|
||||||
case *sql.DeleteStatement:
|
case *sql.DeleteStatement:
|
||||||
i.err = &TableError{table: tb.Name.ID}
|
i.err = &TableError{table: tb.Name.VA}
|
||||||
case *sql.RelateStatement:
|
case *sql.RelateStatement:
|
||||||
i.err = &TableError{table: tb.Name.ID}
|
i.err = &TableError{table: tb.Name.VA}
|
||||||
case *sql.InsertStatement:
|
case *sql.InsertStatement:
|
||||||
i.err = &TableError{table: tb.Name.ID}
|
i.err = &TableError{table: tb.Name.VA}
|
||||||
case *sql.UpsertStatement:
|
case *sql.UpsertStatement:
|
||||||
i.err = &TableError{table: tb.Name.ID}
|
i.err = &TableError{table: tb.Name.VA}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,7 +490,7 @@ func (i *iterator) processPerms(ctx context.Context, nsv, dbv, tbv string) {
|
||||||
|
|
||||||
switch p := tb.Perms.(type) {
|
switch p := tb.Perms.(type) {
|
||||||
default:
|
default:
|
||||||
i.err = &PermsError{table: tb.Name.ID}
|
i.err = &PermsError{table: tb.Name.VA}
|
||||||
case *sql.PermExpression:
|
case *sql.PermExpression:
|
||||||
switch i.stm.(type) {
|
switch i.stm.(type) {
|
||||||
case *sql.SelectStatement:
|
case *sql.SelectStatement:
|
||||||
|
|
|
@ -27,15 +27,15 @@ func (e *executor) executeLet(ctx context.Context, stm *sql.LetStatement) (out [
|
||||||
|
|
||||||
switch what := stm.What.(type) {
|
switch what := stm.What.(type) {
|
||||||
case *sql.Void:
|
case *sql.Void:
|
||||||
vars.Del(stm.Name.ID)
|
vars.Del(stm.Name.VA)
|
||||||
case *sql.Empty:
|
case *sql.Empty:
|
||||||
vars.Del(stm.Name.ID)
|
vars.Del(stm.Name.VA)
|
||||||
default:
|
default:
|
||||||
val, err := e.fetch(ctx, what, nil)
|
val, err := e.fetch(ctx, what, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
vars.Set(val, stm.Name.ID)
|
vars.Set(val, stm.Name.VA)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
14
db/merge.go
14
db/merge.go
|
@ -120,7 +120,7 @@ func (d *document) delFld(ctx context.Context, met method) (err error) {
|
||||||
d.current.Walk(func(key string, val interface{}, ok bool) (err error) {
|
d.current.Walk(func(key string, val interface{}, ok bool) (err error) {
|
||||||
keys[key] = struct{}{}
|
keys[key] = struct{}{}
|
||||||
return
|
return
|
||||||
}, fd.Name.ID)
|
}, fd.Name.VA)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete any keys which aren't allowed
|
// Delete any keys which aren't allowed
|
||||||
|
@ -247,14 +247,14 @@ func (d *document) mrgSet(ctx context.Context, met method, expr *sql.DataExpress
|
||||||
case sql.EQ:
|
case sql.EQ:
|
||||||
switch n.(type) {
|
switch n.(type) {
|
||||||
default:
|
default:
|
||||||
d.current.Set(n, i.ID)
|
d.current.Set(n, i.VA)
|
||||||
case *sql.Void:
|
case *sql.Void:
|
||||||
d.current.Del(i.ID)
|
d.current.Del(i.VA)
|
||||||
}
|
}
|
||||||
case sql.INC:
|
case sql.INC:
|
||||||
d.current.Inc(n, i.ID)
|
d.current.Inc(n, i.VA)
|
||||||
case sql.DEC:
|
case sql.DEC:
|
||||||
d.current.Dec(n, i.ID)
|
d.current.Dec(n, i.VA)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -287,6 +287,8 @@ func (d *document) mrgFld(ctx context.Context, met method) (err error) {
|
||||||
// using json, there is no specific type
|
// using json, there is no specific type
|
||||||
// for a 'datetime' and 'record'.
|
// for a 'datetime' and 'record'.
|
||||||
|
|
||||||
|
// IMPORTANT remove this, and put it in SQL parser
|
||||||
|
|
||||||
d.current.Each(func(key string, val interface{}) (err error) {
|
d.current.Each(func(key string, val interface{}) (err error) {
|
||||||
if val, ok := conv.MightBe(val); ok {
|
if val, ok := conv.MightBe(val); ok {
|
||||||
d.current.Iff(val, key)
|
d.current.Iff(val, key)
|
||||||
|
@ -423,7 +425,7 @@ func (d *document) mrgFld(ctx context.Context, met method) (err error) {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}, fd.Name.ID)
|
}, fd.Name.VA)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
|
@ -88,7 +88,7 @@ func (d *document) perms(ctx context.Context, doc *data.Doc) (err error) {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}, fd.Name.ID)
|
}, fd.Name.VA)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ func (e *executor) executeRelate(ctx context.Context, stm *sql.RelateStatement)
|
||||||
i.processThing(ctx, key)
|
i.processThing(ctx, key)
|
||||||
|
|
||||||
case *sql.Ident:
|
case *sql.Ident:
|
||||||
key := &keys.Thing{KV: stm.KV, NS: stm.NS, DB: stm.DB, TB: what.ID, ID: guid.New().String()}
|
key := &keys.Thing{KV: stm.KV, NS: stm.NS, DB: stm.DB, TB: what.VA, ID: guid.New().String()}
|
||||||
i.processThing(ctx, key)
|
i.processThing(ctx, key)
|
||||||
|
|
||||||
// Result of subquery
|
// Result of subquery
|
||||||
|
|
36
db/remove.go
36
db/remove.go
|
@ -23,14 +23,14 @@ import (
|
||||||
|
|
||||||
func (e *executor) executeRemoveNamespace(ctx context.Context, ast *sql.RemoveNamespaceStatement) (out []interface{}, err error) {
|
func (e *executor) executeRemoveNamespace(ctx context.Context, ast *sql.RemoveNamespaceStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
e.dbo.DelNS(ast.Name.ID)
|
e.dbo.DelNS(ast.Name.VA)
|
||||||
|
|
||||||
// Remove the namespace definition
|
// Remove the namespace definition
|
||||||
nkey := &keys.NS{KV: ast.KV, NS: ast.Name.ID}
|
nkey := &keys.NS{KV: ast.KV, NS: ast.Name.VA}
|
||||||
_, err = e.dbo.Clr(ctx, nkey.Encode())
|
_, err = e.dbo.Clr(ctx, nkey.Encode())
|
||||||
|
|
||||||
// Remove the namespace resource data
|
// Remove the namespace resource data
|
||||||
akey := &keys.Namespace{KV: ast.KV, NS: ast.Name.ID}
|
akey := &keys.Namespace{KV: ast.KV, NS: ast.Name.VA}
|
||||||
_, err = e.dbo.ClrP(ctx, akey.Encode(), 0)
|
_, err = e.dbo.ClrP(ctx, akey.Encode(), 0)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -39,14 +39,14 @@ func (e *executor) executeRemoveNamespace(ctx context.Context, ast *sql.RemoveNa
|
||||||
|
|
||||||
func (e *executor) executeRemoveDatabase(ctx context.Context, ast *sql.RemoveDatabaseStatement) (out []interface{}, err error) {
|
func (e *executor) executeRemoveDatabase(ctx context.Context, ast *sql.RemoveDatabaseStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
e.dbo.DelDB(ast.NS, ast.Name.ID)
|
e.dbo.DelDB(ast.NS, ast.Name.VA)
|
||||||
|
|
||||||
// Remove the database definition
|
// Remove the database definition
|
||||||
dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.Name.ID}
|
dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.Name.VA}
|
||||||
_, err = e.dbo.Clr(ctx, dkey.Encode())
|
_, err = e.dbo.Clr(ctx, dkey.Encode())
|
||||||
|
|
||||||
// Remove the database resource data
|
// Remove the database resource data
|
||||||
akey := &keys.Database{KV: ast.KV, NS: ast.NS, DB: ast.Name.ID}
|
akey := &keys.Database{KV: ast.KV, NS: ast.NS, DB: ast.Name.VA}
|
||||||
_, err = e.dbo.ClrP(ctx, akey.Encode(), 0)
|
_, err = e.dbo.ClrP(ctx, akey.Encode(), 0)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -59,13 +59,13 @@ func (e *executor) executeRemoveLogin(ctx context.Context, ast *sql.RemoveLoginS
|
||||||
case sql.NAMESPACE:
|
case sql.NAMESPACE:
|
||||||
|
|
||||||
// Remove the login definition
|
// Remove the login definition
|
||||||
ukey := &keys.NU{KV: ast.KV, NS: ast.NS, US: ast.User.ID}
|
ukey := &keys.NU{KV: ast.KV, NS: ast.NS, US: ast.User.VA}
|
||||||
_, err = e.dbo.ClrP(ctx, ukey.Encode(), 0)
|
_, err = e.dbo.ClrP(ctx, ukey.Encode(), 0)
|
||||||
|
|
||||||
case sql.DATABASE:
|
case sql.DATABASE:
|
||||||
|
|
||||||
// Remove the login definition
|
// Remove the login definition
|
||||||
ukey := &keys.DU{KV: ast.KV, NS: ast.NS, DB: ast.DB, US: ast.User.ID}
|
ukey := &keys.DU{KV: ast.KV, NS: ast.NS, DB: ast.DB, US: ast.User.VA}
|
||||||
_, err = e.dbo.ClrP(ctx, ukey.Encode(), 0)
|
_, err = e.dbo.ClrP(ctx, ukey.Encode(), 0)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -80,13 +80,13 @@ func (e *executor) executeRemoveToken(ctx context.Context, ast *sql.RemoveTokenS
|
||||||
case sql.NAMESPACE:
|
case sql.NAMESPACE:
|
||||||
|
|
||||||
// Remove the token definition
|
// Remove the token definition
|
||||||
tkey := &keys.NT{KV: ast.KV, NS: ast.NS, TK: ast.Name.ID}
|
tkey := &keys.NT{KV: ast.KV, NS: ast.NS, TK: ast.Name.VA}
|
||||||
_, err = e.dbo.ClrP(ctx, tkey.Encode(), 0)
|
_, err = e.dbo.ClrP(ctx, tkey.Encode(), 0)
|
||||||
|
|
||||||
case sql.DATABASE:
|
case sql.DATABASE:
|
||||||
|
|
||||||
// Remove the token definition
|
// Remove the token definition
|
||||||
tkey := &keys.DT{KV: ast.KV, NS: ast.NS, DB: ast.DB, TK: ast.Name.ID}
|
tkey := &keys.DT{KV: ast.KV, NS: ast.NS, DB: ast.DB, TK: ast.Name.VA}
|
||||||
_, err = e.dbo.ClrP(ctx, tkey.Encode(), 0)
|
_, err = e.dbo.ClrP(ctx, tkey.Encode(), 0)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ func (e *executor) executeRemoveToken(ctx context.Context, ast *sql.RemoveTokenS
|
||||||
func (e *executor) executeRemoveScope(ctx context.Context, ast *sql.RemoveScopeStatement) (out []interface{}, err error) {
|
func (e *executor) executeRemoveScope(ctx context.Context, ast *sql.RemoveScopeStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
// Remove the scope definition
|
// Remove the scope definition
|
||||||
skey := &keys.SC{KV: ast.KV, NS: ast.NS, DB: ast.DB, SC: ast.Name.ID}
|
skey := &keys.SC{KV: ast.KV, NS: ast.NS, DB: ast.DB, SC: ast.Name.VA}
|
||||||
_, err = e.dbo.ClrP(ctx, skey.Encode(), 0)
|
_, err = e.dbo.ClrP(ctx, skey.Encode(), 0)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -109,10 +109,10 @@ func (e *executor) executeRemoveEvent(ctx context.Context, ast *sql.RemoveEventS
|
||||||
|
|
||||||
for _, TB := range ast.What {
|
for _, TB := range ast.What {
|
||||||
|
|
||||||
e.dbo.DelEV(ast.NS, ast.DB, TB.TB, ast.Name.ID)
|
e.dbo.DelEV(ast.NS, ast.DB, TB.TB, ast.Name.VA)
|
||||||
|
|
||||||
// Remove the event definition
|
// Remove the event definition
|
||||||
ekey := &keys.EV{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB.TB, EV: ast.Name.ID}
|
ekey := &keys.EV{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB.TB, EV: ast.Name.VA}
|
||||||
if _, err = e.dbo.ClrP(ctx, ekey.Encode(), 0); err != nil {
|
if _, err = e.dbo.ClrP(ctx, ekey.Encode(), 0); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -127,10 +127,10 @@ func (e *executor) executeRemoveField(ctx context.Context, ast *sql.RemoveFieldS
|
||||||
|
|
||||||
for _, TB := range ast.What {
|
for _, TB := range ast.What {
|
||||||
|
|
||||||
e.dbo.DelFD(ast.NS, ast.DB, TB.TB, ast.Name.ID)
|
e.dbo.DelFD(ast.NS, ast.DB, TB.TB, ast.Name.VA)
|
||||||
|
|
||||||
// Remove the field definition
|
// Remove the field definition
|
||||||
fkey := &keys.FD{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB.TB, FD: ast.Name.ID}
|
fkey := &keys.FD{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB.TB, FD: ast.Name.VA}
|
||||||
if _, err = e.dbo.ClrP(ctx, fkey.Encode(), 0); err != nil {
|
if _, err = e.dbo.ClrP(ctx, fkey.Encode(), 0); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -145,16 +145,16 @@ func (e *executor) executeRemoveIndex(ctx context.Context, ast *sql.RemoveIndexS
|
||||||
|
|
||||||
for _, TB := range ast.What {
|
for _, TB := range ast.What {
|
||||||
|
|
||||||
e.dbo.DelIX(ast.NS, ast.DB, TB.TB, ast.Name.ID)
|
e.dbo.DelIX(ast.NS, ast.DB, TB.TB, ast.Name.VA)
|
||||||
|
|
||||||
// Remove the index definition
|
// Remove the index definition
|
||||||
ikey := &keys.IX{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB.TB, IX: ast.Name.ID}
|
ikey := &keys.IX{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB.TB, IX: ast.Name.VA}
|
||||||
if _, err = e.dbo.ClrP(ctx, ikey.Encode(), 0); err != nil {
|
if _, err = e.dbo.ClrP(ctx, ikey.Encode(), 0); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the index resource data
|
// Remove the index resource data
|
||||||
dkey := &keys.Index{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB.TB, IX: ast.Name.ID, FD: keys.Ignore}
|
dkey := &keys.Index{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB.TB, IX: ast.Name.VA, FD: keys.Ignore}
|
||||||
if _, err = e.dbo.ClrP(ctx, dkey.Encode(), 0); err != nil {
|
if _, err = e.dbo.ClrP(ctx, dkey.Encode(), 0); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ func (e *executor) executeSelect(ctx context.Context, stm *sql.SelectStatement)
|
||||||
i.processTable(ctx, key)
|
i.processTable(ctx, key)
|
||||||
|
|
||||||
case *sql.Ident:
|
case *sql.Ident:
|
||||||
key := &keys.Table{KV: stm.KV, NS: stm.NS, DB: stm.DB, TB: what.ID}
|
key := &keys.Table{KV: stm.KV, NS: stm.NS, DB: stm.DB, TB: what.VA}
|
||||||
i.processTable(ctx, key)
|
i.processTable(ctx, key)
|
||||||
|
|
||||||
case *sql.Thing:
|
case *sql.Thing:
|
||||||
|
|
|
@ -212,7 +212,7 @@ func (s *socket) deregister(id string) {
|
||||||
|
|
||||||
case *sql.Ident:
|
case *sql.Ident:
|
||||||
|
|
||||||
key := &keys.LV{KV: stm.KV, NS: stm.NS, DB: stm.DB, TB: what.ID, LV: id}
|
key := &keys.LV{KV: stm.KV, NS: stm.NS, DB: stm.DB, TB: what.VA, LV: id}
|
||||||
txn.Clr(ctx, key.Encode())
|
txn.Clr(ctx, key.Encode())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ func (s *socket) executeLive(e *executor, ctx context.Context, stm *sql.LiveStat
|
||||||
return nil, err
|
return nil, err
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
key := &keys.LV{KV: stm.KV, NS: stm.NS, DB: stm.DB, TB: what.ID, LV: stm.ID}
|
key := &keys.LV{KV: stm.KV, NS: stm.NS, DB: stm.DB, TB: what.VA, LV: stm.ID}
|
||||||
if _, err = e.dbo.Put(ctx, 0, key.Encode(), stm.Encode()); err != nil {
|
if _, err = e.dbo.Put(ctx, 0, key.Encode(), stm.Encode()); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -328,7 +328,7 @@ func (s *socket) executeKill(e *executor, ctx context.Context, stm *sql.KillStat
|
||||||
_, err = e.dbo.Clr(ctx, key.Encode())
|
_, err = e.dbo.Clr(ctx, key.Encode())
|
||||||
|
|
||||||
case *sql.Ident:
|
case *sql.Ident:
|
||||||
key := &keys.LV{KV: qry.KV, NS: qry.NS, DB: qry.DB, TB: what.ID, LV: qry.ID}
|
key := &keys.LV{KV: qry.KV, NS: qry.NS, DB: qry.DB, TB: what.VA, LV: qry.ID}
|
||||||
_, err = e.dbo.Clr(ctx, key.Encode())
|
_, err = e.dbo.Clr(ctx, key.Encode())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,8 +76,8 @@ func (d *document) table(ctx context.Context, when method) (err error) {
|
||||||
now[k], _ = d.i.e.fetch(ctx, e.Expr, d.current)
|
now[k], _ = d.i.e.fetch(ctx, e.Expr, d.current)
|
||||||
}
|
}
|
||||||
|
|
||||||
prv = sql.NewThing(ft.Name.ID, fmt.Sprintf("%v", old))
|
prv = sql.NewThing(ft.Name.VA, fmt.Sprintf("%v", old))
|
||||||
doc = sql.NewThing(ft.Name.ID, fmt.Sprintf("%v", now))
|
doc = sql.NewThing(ft.Name.VA, fmt.Sprintf("%v", now))
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ func (d *document) table(ctx context.Context, when method) (err error) {
|
||||||
// current record as the basis of the
|
// current record as the basis of the
|
||||||
// new record in the other table.
|
// new record in the other table.
|
||||||
|
|
||||||
doc = sql.NewThing(ft.Name.ID, d.id.ID)
|
doc = sql.NewThing(ft.Name.VA, d.id.ID)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ func (e *executor) executeUpdate(ctx context.Context, stm *sql.UpdateStatement)
|
||||||
i.processTable(ctx, key)
|
i.processTable(ctx, key)
|
||||||
|
|
||||||
case *sql.Ident:
|
case *sql.Ident:
|
||||||
key := &keys.Table{KV: stm.KV, NS: stm.NS, DB: stm.DB, TB: what.ID}
|
key := &keys.Table{KV: stm.KV, NS: stm.NS, DB: stm.DB, TB: what.VA}
|
||||||
i.processTable(ctx, key)
|
i.processTable(ctx, key)
|
||||||
|
|
||||||
case *sql.Thing:
|
case *sql.Thing:
|
||||||
|
|
|
@ -263,7 +263,7 @@ func (d *document) yield(ctx context.Context, stm sql.Statement, output sql.Toke
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}, v.ID)
|
}, v.VA)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13119
sql/ast.gen.go
13119
sql/ast.gen.go
File diff suppressed because it is too large
Load diff
552
sql/ast.go
552
sql/ast.go
|
@ -72,8 +72,8 @@ type CommitStatement struct{}
|
||||||
|
|
||||||
// UseStatement represents a SQL USE statement.
|
// UseStatement represents a SQL USE statement.
|
||||||
type UseStatement struct {
|
type UseStatement struct {
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
@ -82,11 +82,11 @@ type UseStatement struct {
|
||||||
|
|
||||||
// InfoStatement represents an SQL INFO statement.
|
// InfoStatement represents an SQL INFO statement.
|
||||||
type InfoStatement struct {
|
type InfoStatement struct {
|
||||||
KV string `cork:"-" codec:"-"`
|
KV string
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
Kind Token `cork:"-" codec:"-"`
|
Kind Token
|
||||||
What *Table `cork:"-" codec:"-"`
|
What *Table
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
@ -95,10 +95,10 @@ type InfoStatement struct {
|
||||||
|
|
||||||
// IfStatement represents an if else clause.
|
// IfStatement represents an if else clause.
|
||||||
type IfStatement struct {
|
type IfStatement struct {
|
||||||
RW bool `cork:"-" codec:"-"`
|
RW bool
|
||||||
Cond Exprs `cork:"cond" codec:"cond"`
|
Cond Exprs
|
||||||
Then Exprs `cork:"then" codec:"then"`
|
Then Exprs
|
||||||
Else Expr `cork:"else" codec:"else"`
|
Else Expr
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
@ -107,8 +107,8 @@ type IfStatement struct {
|
||||||
|
|
||||||
// RunStatement represents a run clause.
|
// RunStatement represents a run clause.
|
||||||
type RunStatement struct {
|
type RunStatement struct {
|
||||||
RW bool `cork:"-" codec:"-"`
|
RW bool
|
||||||
Expr Expr `cork:"expr" codec:"expr"`
|
Expr Expr
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
@ -117,21 +117,21 @@ type RunStatement struct {
|
||||||
|
|
||||||
// LetStatement represents a SQL LET statement.
|
// LetStatement represents a SQL LET statement.
|
||||||
type LetStatement struct {
|
type LetStatement struct {
|
||||||
RW bool `cork:"-" codec:"-"`
|
RW bool
|
||||||
KV string `cork:"-" codec:"-"`
|
KV string
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
Name *Ident `cork:"-" codec:"-"`
|
Name *Ident
|
||||||
What Expr `cork:"-" codec:"-"`
|
What Expr
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReturnStatement represents a SQL RETURN statement.
|
// ReturnStatement represents a SQL RETURN statement.
|
||||||
type ReturnStatement struct {
|
type ReturnStatement struct {
|
||||||
RW bool `cork:"-" codec:"-"`
|
RW bool
|
||||||
KV string `cork:"-" codec:"-"`
|
KV string
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
What Exprs `cork:"-" codec:"-"`
|
What Exprs
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
@ -140,121 +140,121 @@ type ReturnStatement struct {
|
||||||
|
|
||||||
// LiveStatement represents a SQL LIVE statement.
|
// LiveStatement represents a SQL LIVE statement.
|
||||||
type LiveStatement struct {
|
type LiveStatement struct {
|
||||||
ID string `cork:"ID" codec:"ID"`
|
ID string
|
||||||
FB string `cork:"FB" codec:"FB"`
|
FB string
|
||||||
KV string `cork:"KV" codec:"KV"`
|
KV string
|
||||||
NS string `cork:"NS" codec:"NS"`
|
NS string
|
||||||
DB string `cork:"DB" codec:"DB"`
|
DB string
|
||||||
Diff bool `cork:"diff" codec:"diff"`
|
Diff bool
|
||||||
Expr Fields `cork:"expr" codec:"expr"`
|
Expr Fields
|
||||||
What Exprs `cork:"what" codec:"what"`
|
What Exprs
|
||||||
Cond Expr `cork:"cond" codec:"cond"`
|
Cond Expr
|
||||||
Fetch Fetchs `cork:"fetch" codec:"fetch"`
|
Fetch Fetchs
|
||||||
}
|
}
|
||||||
|
|
||||||
// KillStatement represents a SQL KILL statement.
|
// KillStatement represents a SQL KILL statement.
|
||||||
type KillStatement struct {
|
type KillStatement struct {
|
||||||
FB string `cork:"FB" codec:"FB"`
|
FB string
|
||||||
KV string `cork:"KV" codec:"KV"`
|
KV string
|
||||||
NS string `cork:"NS" codec:"NS"`
|
NS string
|
||||||
DB string `cork:"DB" codec:"DB"`
|
DB string
|
||||||
What Exprs `cork:"what" codec:"what"`
|
What Exprs
|
||||||
}
|
}
|
||||||
|
|
||||||
// SelectStatement represents a SQL SELECT statement.
|
// SelectStatement represents a SQL SELECT statement.
|
||||||
type SelectStatement struct {
|
type SelectStatement struct {
|
||||||
RW bool `cork:"-" codec:"-"`
|
RW bool
|
||||||
KV string `cork:"KV" codec:"KV"`
|
KV string
|
||||||
NS string `cork:"NS" codec:"NS"`
|
NS string
|
||||||
DB string `cork:"DB" codec:"DB"`
|
DB string
|
||||||
Expr Fields `cork:"expr" codec:"expr"`
|
Expr Fields
|
||||||
What Exprs `cork:"what" codec:"what"`
|
What Exprs
|
||||||
Cond Expr `cork:"cond" codec:"cond"`
|
Cond Expr
|
||||||
Group Groups `cork:"group" codec:"group"`
|
Group Groups
|
||||||
Order Orders `cork:"order" codec:"order"`
|
Order Orders
|
||||||
Limit Expr `cork:"limit" codec:"limit"`
|
Limit Expr
|
||||||
Start Expr `cork:"start" codec:"start"`
|
Start Expr
|
||||||
Fetch Fetchs `cork:"fetch" codec:"fetch"`
|
Fetch Fetchs
|
||||||
Version Expr `cork:"version" codec:"version"`
|
Version Expr
|
||||||
Timeout time.Duration `cork:"timeout" codec:"timeout"`
|
Timeout time.Duration
|
||||||
Parallel int `cork:"parallel" codec:"parallel"`
|
Parallel int
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateStatement represents a SQL CREATE statement.
|
// CreateStatement represents a SQL CREATE statement.
|
||||||
type CreateStatement struct {
|
type CreateStatement struct {
|
||||||
KV string `cork:"KV" codec:"KV"`
|
KV string
|
||||||
NS string `cork:"NS" codec:"NS"`
|
NS string
|
||||||
DB string `cork:"DB" codec:"DB"`
|
DB string
|
||||||
What Exprs `cork:"what" codec:"what"`
|
What Exprs
|
||||||
Data Expr `cork:"data" codec:"data"`
|
Data Expr
|
||||||
Echo Token `cork:"echo" codec:"echo"`
|
Echo Token
|
||||||
Timeout time.Duration `cork:"timeout" codec:"timeout"`
|
Timeout time.Duration
|
||||||
Parallel int `cork:"parallel" codec:"parallel"`
|
Parallel int
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateStatement represents a SQL UPDATE statement.
|
// UpdateStatement represents a SQL UPDATE statement.
|
||||||
type UpdateStatement struct {
|
type UpdateStatement struct {
|
||||||
KV string `cork:"KV" codec:"KV"`
|
KV string
|
||||||
NS string `cork:"NS" codec:"NS"`
|
NS string
|
||||||
DB string `cork:"DB" codec:"DB"`
|
DB string
|
||||||
What Exprs `cork:"what" codec:"what"`
|
What Exprs
|
||||||
Data Expr `cork:"data" codec:"data"`
|
Data Expr
|
||||||
Cond Expr `cork:"cond" codec:"cond"`
|
Cond Expr
|
||||||
Echo Token `cork:"echo" codec:"echo"`
|
Echo Token
|
||||||
Timeout time.Duration `cork:"timeout" codec:"timeout"`
|
Timeout time.Duration
|
||||||
Parallel int `cork:"parallel" codec:"parallel"`
|
Parallel int
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteStatement represents a SQL DELETE statement.
|
// DeleteStatement represents a SQL DELETE statement.
|
||||||
type DeleteStatement struct {
|
type DeleteStatement struct {
|
||||||
KV string `cork:"KV" codec:"KV"`
|
KV string
|
||||||
NS string `cork:"NS" codec:"NS"`
|
NS string
|
||||||
DB string `cork:"DB" codec:"DB"`
|
DB string
|
||||||
Hard bool `cork:"hard" codec:"hard"`
|
Hard bool
|
||||||
What Exprs `cork:"what" codec:"what"`
|
What Exprs
|
||||||
Cond Expr `cork:"cond" codec:"cond"`
|
Cond Expr
|
||||||
Echo Token `cork:"echo" codec:"echo"`
|
Echo Token
|
||||||
Timeout time.Duration `cork:"timeout" codec:"timeout"`
|
Timeout time.Duration
|
||||||
Parallel int `cork:"parallel" codec:"parallel"`
|
Parallel int
|
||||||
}
|
}
|
||||||
|
|
||||||
// RelateStatement represents a SQL RELATE statement.
|
// RelateStatement represents a SQL RELATE statement.
|
||||||
type RelateStatement struct {
|
type RelateStatement struct {
|
||||||
KV string `cork:"KV" codec:"KV"`
|
KV string
|
||||||
NS string `cork:"NS" codec:"NS"`
|
NS string
|
||||||
DB string `cork:"DB" codec:"DB"`
|
DB string
|
||||||
Type Expr `cork:"type" codec:"type"`
|
Type Expr
|
||||||
From Exprs `cork:"from" codec:"from"`
|
From Exprs
|
||||||
With Exprs `cork:"with" codec:"with"`
|
With Exprs
|
||||||
Data Expr `cork:"data" codec:"data"`
|
Data Expr
|
||||||
Uniq bool `cork:"uniq" codec:"uniq"`
|
Uniq bool
|
||||||
Echo Token `cork:"echo" codec:"echo"`
|
Echo Token
|
||||||
Timeout time.Duration `cork:"timeout" codec:"timeout"`
|
Timeout time.Duration
|
||||||
Parallel int `cork:"parallel" codec:"parallel"`
|
Parallel int
|
||||||
}
|
}
|
||||||
|
|
||||||
// InsertStatement represents a SQL INSERT statement.
|
// InsertStatement represents a SQL INSERT statement.
|
||||||
type InsertStatement struct {
|
type InsertStatement struct {
|
||||||
KV string `cork:"KV" codec:"KV"`
|
KV string
|
||||||
NS string `cork:"NS" codec:"NS"`
|
NS string
|
||||||
DB string `cork:"DB" codec:"DB"`
|
DB string
|
||||||
Data Expr `cork:"data" codec:"data"`
|
Data Expr
|
||||||
Into *Table `cork:"into" codec:"into"`
|
Into *Table
|
||||||
Echo Token `cork:"echo" codec:"echo"`
|
Echo Token
|
||||||
Timeout time.Duration `cork:"timeout" codec:"timeout"`
|
Timeout time.Duration
|
||||||
Parallel int `cork:"parallel" codec:"parallel"`
|
Parallel int
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpsertStatement represents a SQL UPSERT statement.
|
// UpsertStatement represents a SQL UPSERT statement.
|
||||||
type UpsertStatement struct {
|
type UpsertStatement struct {
|
||||||
KV string `cork:"KV" codec:"KV"`
|
KV string
|
||||||
NS string `cork:"NS" codec:"NS"`
|
NS string
|
||||||
DB string `cork:"DB" codec:"DB"`
|
DB string
|
||||||
Data Expr `cork:"data" codec:"data"`
|
Data Expr
|
||||||
Into *Table `cork:"into" codec:"into"`
|
Into *Table
|
||||||
Echo Token `cork:"echo" codec:"echo"`
|
Echo Token
|
||||||
Timeout time.Duration `cork:"timeout" codec:"timeout"`
|
Timeout time.Duration
|
||||||
Parallel int `cork:"parallel" codec:"parallel"`
|
Parallel int
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
@ -262,17 +262,17 @@ type UpsertStatement struct {
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
type DefineNamespaceStatement struct {
|
type DefineNamespaceStatement struct {
|
||||||
KV string `cork:"-" codec:"-"`
|
KV string
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
Name *Ident `cork:"name" codec:"name"`
|
Name *Ident
|
||||||
}
|
}
|
||||||
|
|
||||||
type RemoveNamespaceStatement struct {
|
type RemoveNamespaceStatement struct {
|
||||||
KV string `cork:"-" codec:"-"`
|
KV string
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
Name *Ident `cork:"name" codec:"name"`
|
Name *Ident
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
@ -280,17 +280,17 @@ type RemoveNamespaceStatement struct {
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
type DefineDatabaseStatement struct {
|
type DefineDatabaseStatement struct {
|
||||||
KV string `cork:"-" codec:"-"`
|
KV string
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
Name *Ident `cork:"name" codec:"name"`
|
Name *Ident
|
||||||
}
|
}
|
||||||
|
|
||||||
type RemoveDatabaseStatement struct {
|
type RemoveDatabaseStatement struct {
|
||||||
KV string `cork:"-" codec:"-"`
|
KV string
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
Name *Ident `cork:"name" codec:"name"`
|
Name *Ident
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
@ -299,22 +299,22 @@ type RemoveDatabaseStatement struct {
|
||||||
|
|
||||||
// DefineLoginStatement represents an SQL DEFINE LOGIN statement.
|
// DefineLoginStatement represents an SQL DEFINE LOGIN statement.
|
||||||
type DefineLoginStatement struct {
|
type DefineLoginStatement struct {
|
||||||
KV string `cork:"-" codec:"-"`
|
KV string
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
Kind Token `cork:"kind" codec:"kind"`
|
Kind Token
|
||||||
User *Ident `cork:"user" codec:"user"`
|
User *Ident
|
||||||
Pass []byte `cork:"pass" codec:"pass"`
|
Pass []byte
|
||||||
Code []byte `cork:"code" codec:"code"`
|
Code []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveLoginStatement represents an SQL REMOVE LOGIN statement.
|
// RemoveLoginStatement represents an SQL REMOVE LOGIN statement.
|
||||||
type RemoveLoginStatement struct {
|
type RemoveLoginStatement struct {
|
||||||
KV string `cork:"-" codec:"-"`
|
KV string
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
Kind Token `cork:"kind" codec:"kind"`
|
Kind Token
|
||||||
User *Ident `cork:"user" codec:"user"`
|
User *Ident
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
@ -323,22 +323,22 @@ type RemoveLoginStatement struct {
|
||||||
|
|
||||||
// DefineTokenStatement represents an SQL DEFINE TOKEN statement.
|
// DefineTokenStatement represents an SQL DEFINE TOKEN statement.
|
||||||
type DefineTokenStatement struct {
|
type DefineTokenStatement struct {
|
||||||
KV string `cork:"-" codec:"-"`
|
KV string
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
Kind Token `cork:"kind" codec:"kind"`
|
Kind Token
|
||||||
Name *Ident `cork:"name" codec:"name"`
|
Name *Ident
|
||||||
Type string `cork:"type" codec:"type"`
|
Type string
|
||||||
Code []byte `cork:"code" codec:"code"`
|
Code []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveTokenStatement represents an SQL REMOVE TOKEN statement.
|
// RemoveTokenStatement represents an SQL REMOVE TOKEN statement.
|
||||||
type RemoveTokenStatement struct {
|
type RemoveTokenStatement struct {
|
||||||
KV string `cork:"-" codec:"-"`
|
KV string
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
Kind Token `cork:"kind" codec:"kind"`
|
Kind Token
|
||||||
Name *Ident `cork:"name" codec:"name"`
|
Name *Ident
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
@ -347,25 +347,25 @@ type RemoveTokenStatement struct {
|
||||||
|
|
||||||
// DefineScopeStatement represents an SQL DEFINE SCOPE statement.
|
// DefineScopeStatement represents an SQL DEFINE SCOPE statement.
|
||||||
type DefineScopeStatement struct {
|
type DefineScopeStatement struct {
|
||||||
KV string `cork:"-" codec:"-"`
|
KV string
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
Name *Ident `cork:"name" codec:"name"`
|
Name *Ident
|
||||||
Time time.Duration `cork:"time" codec:"time"`
|
Time time.Duration
|
||||||
Code []byte `cork:"code" codec:"code"`
|
Code []byte
|
||||||
Signup Expr `cork:"signup" codec:"signup"`
|
Signup Expr
|
||||||
Signin Expr `cork:"signin" codec:"signin"`
|
Signin Expr
|
||||||
Connect Expr `cork:"connect" codec:"connect"`
|
Connect Expr
|
||||||
OnSignup Expr `cork:"onsignup" codec:"onsignup"`
|
OnSignup Expr
|
||||||
OnSignin Expr `cork:"onsignin" codec:"onsignin"`
|
OnSignin Expr
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveScopeStatement represents an SQL REMOVE SCOPE statement.
|
// RemoveScopeStatement represents an SQL REMOVE SCOPE statement.
|
||||||
type RemoveScopeStatement struct {
|
type RemoveScopeStatement struct {
|
||||||
KV string `cork:"-" codec:"-"`
|
KV string
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
Name *Ident `cork:"name" codec:"name"`
|
Name *Ident
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
@ -374,27 +374,28 @@ type RemoveScopeStatement struct {
|
||||||
|
|
||||||
// DefineTableStatement represents an SQL DEFINE TABLE statement.
|
// DefineTableStatement represents an SQL DEFINE TABLE statement.
|
||||||
type DefineTableStatement struct {
|
type DefineTableStatement struct {
|
||||||
KV string `cork:"-" codec:"-"`
|
KV string
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
Name *Ident `cork:"name" codec:"name"`
|
Name *Ident
|
||||||
What Tables `cork:"-" codec:"-"`
|
What Tables
|
||||||
Full bool `cork:"full" codec:"full"`
|
Full bool
|
||||||
Drop bool `cork:"drop" codec:"drop"`
|
Vers bool
|
||||||
Lock bool `cork:"lock" codec:"lock"`
|
Drop bool
|
||||||
Expr Fields `cork:"expr" codec:"expr"`
|
Lock bool
|
||||||
From Tables `cork:"from" codec:"from"`
|
Expr Fields
|
||||||
Cond Expr `cork:"cond" codec:"cond"`
|
From Tables
|
||||||
Group Groups `cork:"group" codec:"group"`
|
Cond Expr
|
||||||
Perms Expr `cork:"perms" codec:"perms"`
|
Group Groups
|
||||||
|
Perms Expr
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveTableStatement represents an SQL REMOVE TABLE statement.
|
// RemoveTableStatement represents an SQL REMOVE TABLE statement.
|
||||||
type RemoveTableStatement struct {
|
type RemoveTableStatement struct {
|
||||||
KV string `cork:"-" codec:"-"`
|
KV string
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
What Tables `cork:"-" codec:"-"`
|
What Tables
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
@ -403,22 +404,22 @@ type RemoveTableStatement struct {
|
||||||
|
|
||||||
// DefineEventStatement represents an SQL DEFINE EVENT statement.
|
// DefineEventStatement represents an SQL DEFINE EVENT statement.
|
||||||
type DefineEventStatement struct {
|
type DefineEventStatement struct {
|
||||||
KV string `cork:"-" codec:"-"`
|
KV string
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
Name *Ident `cork:"name" codec:"name"`
|
Name *Ident
|
||||||
What Tables `cork:"-" codec:"-"`
|
What Tables
|
||||||
When Expr `cork:"when" codec:"when"`
|
When Expr
|
||||||
Then Expr `cork:"then" codec:"then"`
|
Then Expr
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveEventStatement represents an SQL REMOVE EVENT statement.
|
// RemoveEventStatement represents an SQL REMOVE EVENT statement.
|
||||||
type RemoveEventStatement struct {
|
type RemoveEventStatement struct {
|
||||||
KV string `cork:"-" codec:"-"`
|
KV string
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
Name *Ident `cork:"-" codec:"-"`
|
Name *Ident
|
||||||
What Tables `cork:"-" codec:"-"`
|
What Tables
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
@ -427,26 +428,26 @@ type RemoveEventStatement struct {
|
||||||
|
|
||||||
// DefineFieldStatement represents an SQL DEFINE FIELD statement.
|
// DefineFieldStatement represents an SQL DEFINE FIELD statement.
|
||||||
type DefineFieldStatement struct {
|
type DefineFieldStatement struct {
|
||||||
KV string `cork:"-" codec:"-"`
|
KV string
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
Name *Ident `cork:"name" codec:"name"`
|
Name *Ident
|
||||||
What Tables `cork:"-" codec:"-"`
|
What Tables
|
||||||
Perms Expr `cork:"perms" codec:"perms"`
|
Perms Expr
|
||||||
Type string `cork:"type" codec:"type"`
|
Type string
|
||||||
Kind string `cork:"kind" codec:"kind"`
|
Kind string
|
||||||
Value Expr `cork:"value" codec:"value"`
|
Value Expr
|
||||||
Assert Expr `cork:"assert" codec:"assert"`
|
Assert Expr
|
||||||
Priority float64 `cork:"priority" codec:"priority"`
|
Priority float64
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveFieldStatement represents an SQL REMOVE FIELD statement.
|
// RemoveFieldStatement represents an SQL REMOVE FIELD statement.
|
||||||
type RemoveFieldStatement struct {
|
type RemoveFieldStatement struct {
|
||||||
KV string `cork:"-" codec:"-"`
|
KV string
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
Name *Ident `cork:"-" codec:"-"`
|
Name *Ident
|
||||||
What Tables `cork:"-" codec:"-"`
|
What Tables
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
@ -455,22 +456,22 @@ type RemoveFieldStatement struct {
|
||||||
|
|
||||||
// DefineIndexStatement represents an SQL DEFINE INDEX statement.
|
// DefineIndexStatement represents an SQL DEFINE INDEX statement.
|
||||||
type DefineIndexStatement struct {
|
type DefineIndexStatement struct {
|
||||||
KV string `cork:"-" codec:"-"`
|
KV string
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
Name *Ident `cork:"name" codec:"name"`
|
Name *Ident
|
||||||
What Tables `cork:"-" codec:"-"`
|
What Tables
|
||||||
Cols Idents `cork:"cols" codec:"cols"`
|
Cols Idents
|
||||||
Uniq bool `cork:"uniq" codec:"uniq"`
|
Uniq bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveIndexStatement represents an SQL REMOVE INDEX statement.
|
// RemoveIndexStatement represents an SQL REMOVE INDEX statement.
|
||||||
type RemoveIndexStatement struct {
|
type RemoveIndexStatement struct {
|
||||||
KV string `cork:"-" codec:"-"`
|
KV string
|
||||||
NS string `cork:"-" codec:"-"`
|
NS string
|
||||||
DB string `cork:"-" codec:"-"`
|
DB string
|
||||||
Name *Ident `cork:"-" codec:"-"`
|
Name *Ident
|
||||||
What Tables `cork:"-" codec:"-"`
|
What Tables
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
@ -626,22 +627,6 @@ type ContentExpression struct {
|
||||||
Data Expr
|
Data Expr
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
|
||||||
// Model
|
|
||||||
// --------------------------------------------------
|
|
||||||
|
|
||||||
// Model comment
|
|
||||||
type Model struct {
|
|
||||||
TB string
|
|
||||||
MIN float64
|
|
||||||
INC float64
|
|
||||||
MAX float64
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewModel(TB string, MIN, INC, MAX float64) *Model {
|
|
||||||
return &Model{TB: TB, MIN: MIN, INC: INC, MAX: MAX}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// Param
|
// Param
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
@ -651,43 +636,11 @@ type Params []*Param
|
||||||
|
|
||||||
// Param comment
|
// Param comment
|
||||||
type Param struct {
|
type Param struct {
|
||||||
ID string
|
VA string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewParam(ID string) *Param {
|
func NewParam(VA string) *Param {
|
||||||
return &Param{ID}
|
return &Param{VA}
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------
|
|
||||||
// Regex
|
|
||||||
// --------------------------------------------------
|
|
||||||
|
|
||||||
// Params represents multiple Regex clauses.
|
|
||||||
type Regexs []*Regex
|
|
||||||
|
|
||||||
// Regex comment
|
|
||||||
type Regex struct {
|
|
||||||
ID string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewRegex(ID string) *Regex {
|
|
||||||
return &Regex{ID}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------
|
|
||||||
// Value
|
|
||||||
// --------------------------------------------------
|
|
||||||
|
|
||||||
// Values represents multiple Value clauses.
|
|
||||||
type Values []*Value
|
|
||||||
|
|
||||||
// Value comment
|
|
||||||
type Value struct {
|
|
||||||
ID string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewValue(ID string) *Value {
|
|
||||||
return &Value{ID}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
@ -699,11 +652,43 @@ type Idents []*Ident
|
||||||
|
|
||||||
// Ident comment
|
// Ident comment
|
||||||
type Ident struct {
|
type Ident struct {
|
||||||
ID string
|
VA string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewIdent(ID string) *Ident {
|
func NewIdent(VA string) *Ident {
|
||||||
return &Ident{ID}
|
return &Ident{VA}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------
|
||||||
|
// Value
|
||||||
|
// --------------------------------------------------
|
||||||
|
|
||||||
|
// Values represents multiple Value clauses.
|
||||||
|
type Values []*Value
|
||||||
|
|
||||||
|
// Value comment
|
||||||
|
type Value struct {
|
||||||
|
VA string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewValue(VA string) *Value {
|
||||||
|
return &Value{VA}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------
|
||||||
|
// Regex
|
||||||
|
// --------------------------------------------------
|
||||||
|
|
||||||
|
// Regexs represents multiple Regex clauses.
|
||||||
|
type Regexs []*Regex
|
||||||
|
|
||||||
|
// Regex comment
|
||||||
|
type Regex struct {
|
||||||
|
VA string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewRegex(VA string) *Regex {
|
||||||
|
return &Regex{VA}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
@ -743,6 +728,25 @@ func NewBatch(TB string, BA []interface{}) *Batch {
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------
|
||||||
|
// Model
|
||||||
|
// --------------------------------------------------
|
||||||
|
|
||||||
|
// Models represents multiple Model clauses.
|
||||||
|
type Models []*Model
|
||||||
|
|
||||||
|
// Model comment
|
||||||
|
type Model struct {
|
||||||
|
TB string
|
||||||
|
MIN float64
|
||||||
|
INC float64
|
||||||
|
MAX float64
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewModel(TB string, MIN, INC, MAX float64) *Model {
|
||||||
|
return &Model{TB: TB, MIN: MIN, INC: INC, MAX: MAX}
|
||||||
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// Thing
|
// Thing
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
@ -831,7 +835,7 @@ type Polygons []*Polygon
|
||||||
|
|
||||||
// Polygon comment
|
// Polygon comment
|
||||||
type Polygon struct {
|
type Polygon struct {
|
||||||
PS Points
|
PS []*Point
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPolygon(PS ...*Point) *Polygon {
|
func NewPolygon(PS ...*Point) *Polygon {
|
||||||
|
|
|
@ -28,7 +28,7 @@ func checkExpression(allowed map[string]bool, expr Fields, grps Groups) error {
|
||||||
// see if it exists in the GROUP BY.
|
// see if it exists in the GROUP BY.
|
||||||
|
|
||||||
if i, ok := g.Expr.(*Ident); ok {
|
if i, ok := g.Expr.(*Ident); ok {
|
||||||
if e.Field == i.ID {
|
if e.Field == i.VA {
|
||||||
continue skip
|
continue skip
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1017
sql/cork.go
1017
sql/cork.go
File diff suppressed because it is too large
Load diff
|
@ -112,11 +112,11 @@ func (p *parser) parseFields() (mul Fields, err error) {
|
||||||
|
|
||||||
switch v := one.Expr.(type) {
|
switch v := one.Expr.(type) {
|
||||||
case *Param:
|
case *Param:
|
||||||
one.Field = v.ID
|
one.Field = v.VA
|
||||||
case *Value:
|
|
||||||
one.Field = v.ID
|
|
||||||
case *Ident:
|
case *Ident:
|
||||||
one.Field = v.ID
|
one.Field = v.VA
|
||||||
|
case *Value:
|
||||||
|
one.Field = v.VA
|
||||||
default:
|
default:
|
||||||
one.Field = one.String()
|
one.Field = one.String()
|
||||||
}
|
}
|
||||||
|
|
|
@ -440,7 +440,7 @@ func Test_Parse_Queries_Let(t *testing.T) {
|
||||||
res: &Query{Statements: []Statement{&LetStatement{
|
res: &Query{Statements: []Statement{&LetStatement{
|
||||||
RW: false, KV: "*", NS: "*", DB: "*",
|
RW: false, KV: "*", NS: "*", DB: "*",
|
||||||
Name: &Ident{"name"},
|
Name: &Ident{"name"},
|
||||||
What: &Param{ID: "test"},
|
What: &Param{"test"},
|
||||||
}}},
|
}}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -450,7 +450,7 @@ func Test_Parse_Queries_Let(t *testing.T) {
|
||||||
Name: &Ident{"name"},
|
Name: &Ident{"name"},
|
||||||
What: &SubExpression{Expr: &CreateStatement{
|
What: &SubExpression{Expr: &CreateStatement{
|
||||||
KV: "*", NS: "*", DB: "*",
|
KV: "*", NS: "*", DB: "*",
|
||||||
What: Exprs{&Ident{ID: "person"}},
|
What: Exprs{&Ident{"person"}},
|
||||||
Echo: AFTER,
|
Echo: AFTER,
|
||||||
}},
|
}},
|
||||||
}}},
|
}}},
|
||||||
|
@ -552,7 +552,7 @@ func Test_Parse_Queries_Return(t *testing.T) {
|
||||||
sql: `RETURN $test`,
|
sql: `RETURN $test`,
|
||||||
res: &Query{Statements: []Statement{&ReturnStatement{
|
res: &Query{Statements: []Statement{&ReturnStatement{
|
||||||
RW: false, KV: "*", NS: "*", DB: "*",
|
RW: false, KV: "*", NS: "*", DB: "*",
|
||||||
What: Exprs{&Param{ID: "test"}},
|
What: Exprs{&Param{"test"}},
|
||||||
}}},
|
}}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -561,7 +561,7 @@ func Test_Parse_Queries_Return(t *testing.T) {
|
||||||
RW: true, KV: "*", NS: "*", DB: "*",
|
RW: true, KV: "*", NS: "*", DB: "*",
|
||||||
What: Exprs{&SubExpression{Expr: &CreateStatement{
|
What: Exprs{&SubExpression{Expr: &CreateStatement{
|
||||||
KV: "*", NS: "*", DB: "*",
|
KV: "*", NS: "*", DB: "*",
|
||||||
What: Exprs{&Ident{ID: "person"}},
|
What: Exprs{&Ident{"person"}},
|
||||||
Echo: AFTER,
|
Echo: AFTER,
|
||||||
}}},
|
}}},
|
||||||
}}},
|
}}},
|
||||||
|
@ -850,7 +850,7 @@ func Test_Parse_Queries_Select(t *testing.T) {
|
||||||
},
|
},
|
||||||
What: Exprs{&SubExpression{Expr: &CreateStatement{
|
What: Exprs{&SubExpression{Expr: &CreateStatement{
|
||||||
KV: "*", NS: "*", DB: "*",
|
KV: "*", NS: "*", DB: "*",
|
||||||
What: Exprs{&Ident{ID: "person"}},
|
What: Exprs{&Ident{"person"}},
|
||||||
Echo: AFTER,
|
Echo: AFTER,
|
||||||
}}},
|
}}},
|
||||||
}}},
|
}}},
|
||||||
|
@ -1039,7 +1039,7 @@ func Test_Parse_Queries_Select(t *testing.T) {
|
||||||
},
|
},
|
||||||
Op: AND,
|
Op: AND,
|
||||||
RHS: &BinaryExpression{
|
RHS: &BinaryExpression{
|
||||||
LHS: &Ident{ID: "id"},
|
LHS: &Ident{"id"},
|
||||||
Op: LTE,
|
Op: LTE,
|
||||||
RHS: float64(29.9),
|
RHS: float64(29.9),
|
||||||
},
|
},
|
||||||
|
@ -1151,27 +1151,27 @@ func Test_Parse_Queries_Select(t *testing.T) {
|
||||||
LHS: &BinaryExpression{
|
LHS: &BinaryExpression{
|
||||||
LHS: &BinaryExpression{
|
LHS: &BinaryExpression{
|
||||||
LHS: &BinaryExpression{
|
LHS: &BinaryExpression{
|
||||||
LHS: &Ident{ID: "bday"},
|
LHS: &Ident{"bday"},
|
||||||
Op: GTE,
|
Op: GTE,
|
||||||
RHS: bday1,
|
RHS: bday1,
|
||||||
},
|
},
|
||||||
Op: AND,
|
Op: AND,
|
||||||
RHS: &BinaryExpression{
|
RHS: &BinaryExpression{
|
||||||
LHS: &Ident{ID: "bday"},
|
LHS: &Ident{"bday"},
|
||||||
Op: GTE,
|
Op: GTE,
|
||||||
RHS: bday2,
|
RHS: bday2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Op: AND,
|
Op: AND,
|
||||||
RHS: &BinaryExpression{
|
RHS: &BinaryExpression{
|
||||||
LHS: &Ident{ID: "bday"},
|
LHS: &Ident{"bday"},
|
||||||
Op: GTE,
|
Op: GTE,
|
||||||
RHS: bday3,
|
RHS: bday3,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Op: AND,
|
Op: AND,
|
||||||
RHS: &BinaryExpression{
|
RHS: &BinaryExpression{
|
||||||
LHS: &Ident{ID: "bday"},
|
LHS: &Ident{"bday"},
|
||||||
Op: LTE,
|
Op: LTE,
|
||||||
RHS: bday4,
|
RHS: bday4,
|
||||||
},
|
},
|
||||||
|
@ -2347,7 +2347,7 @@ func Test_Parse_Queries_Define(t *testing.T) {
|
||||||
Signup: &SubExpression{
|
Signup: &SubExpression{
|
||||||
Expr: &CreateStatement{
|
Expr: &CreateStatement{
|
||||||
KV: "*", NS: "*", DB: "*",
|
KV: "*", NS: "*", DB: "*",
|
||||||
What: Exprs{&Ident{ID: "person"}},
|
What: Exprs{&Ident{"person"}},
|
||||||
Echo: AFTER,
|
Echo: AFTER,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -2532,7 +2532,7 @@ func Test_Parse_Queries_Define(t *testing.T) {
|
||||||
Lock: true,
|
Lock: true,
|
||||||
Expr: Fields{
|
Expr: Fields{
|
||||||
&Field{
|
&Field{
|
||||||
Expr: &Ident{ID: "nationality"},
|
Expr: &Ident{"nationality"},
|
||||||
Field: "nationality",
|
Field: "nationality",
|
||||||
},
|
},
|
||||||
&Field{
|
&Field{
|
||||||
|
@ -2549,13 +2549,13 @@ func Test_Parse_Queries_Define(t *testing.T) {
|
||||||
&Table{TB: "users"},
|
&Table{TB: "users"},
|
||||||
},
|
},
|
||||||
Cond: &BinaryExpression{
|
Cond: &BinaryExpression{
|
||||||
LHS: &Ident{ID: "public"},
|
LHS: &Ident{"public"},
|
||||||
Op: EQ,
|
Op: EQ,
|
||||||
RHS: true,
|
RHS: true,
|
||||||
},
|
},
|
||||||
Group: Groups{
|
Group: Groups{
|
||||||
&Group{
|
&Group{
|
||||||
Expr: &Ident{ID: "nationality"},
|
Expr: &Ident{"nationality"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}}},
|
}}},
|
||||||
|
|
110
sql/string.go
110
sql/string.go
|
@ -552,27 +552,6 @@ func (this Fetch) String() string {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------
|
|
||||||
// Model
|
|
||||||
// ---------------------------------------------
|
|
||||||
|
|
||||||
func (this Model) String() string {
|
|
||||||
switch {
|
|
||||||
case this.INC == 0:
|
|
||||||
max := strconv.FormatFloat(this.MAX, 'f', -1, 64)
|
|
||||||
return print("|%s:%s|", quote(this.TB), max)
|
|
||||||
case this.INC == 1:
|
|
||||||
min := strconv.FormatFloat(this.MIN, 'f', -1, 64)
|
|
||||||
max := strconv.FormatFloat(this.MAX, 'f', -1, 64)
|
|
||||||
return print("|%s:%s..%s|", quote(this.TB), min, max)
|
|
||||||
default:
|
|
||||||
inc := strconv.FormatFloat(this.INC, 'f', -1, 64)
|
|
||||||
min := strconv.FormatFloat(this.MIN, 'f', -1, 64)
|
|
||||||
max := strconv.FormatFloat(this.MAX, 'f', -1, 64)
|
|
||||||
return print("|%s:%s,%s..%s|", quote(this.TB), min, inc, max)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------
|
// ---------------------------------------------
|
||||||
// Param
|
// Param
|
||||||
// ---------------------------------------------
|
// ---------------------------------------------
|
||||||
|
@ -586,39 +565,7 @@ func (this Params) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this Param) String() string {
|
func (this Param) String() string {
|
||||||
return print("$%v", this.ID)
|
return print("$%v", this.VA)
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------
|
|
||||||
// Regex
|
|
||||||
// ---------------------------------------------
|
|
||||||
|
|
||||||
func (this Regexs) String() string {
|
|
||||||
m := make([]string, len(this))
|
|
||||||
for k, v := range this {
|
|
||||||
m[k] = v.String()
|
|
||||||
}
|
|
||||||
return strings.Join(m, ", ")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this Regex) String() string {
|
|
||||||
return print("/%v/", this.ID)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------
|
|
||||||
// Value
|
|
||||||
// ---------------------------------------------
|
|
||||||
|
|
||||||
func (this Values) String() string {
|
|
||||||
m := make([]string, len(this))
|
|
||||||
for k, v := range this {
|
|
||||||
m[k] = v.String()
|
|
||||||
}
|
|
||||||
return strings.Join(m, ", ")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this Value) String() string {
|
|
||||||
return print("\"%v\"", this.ID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------
|
// ---------------------------------------------
|
||||||
|
@ -634,7 +581,39 @@ func (this Idents) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this Ident) String() string {
|
func (this Ident) String() string {
|
||||||
return quote(this.ID)
|
return quote(this.VA)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------
|
||||||
|
// Value
|
||||||
|
// ---------------------------------------------
|
||||||
|
|
||||||
|
func (this Values) String() string {
|
||||||
|
m := make([]string, len(this))
|
||||||
|
for k, v := range this {
|
||||||
|
m[k] = v.String()
|
||||||
|
}
|
||||||
|
return strings.Join(m, ", ")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this Value) String() string {
|
||||||
|
return print(`"%v"`, this.VA)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------
|
||||||
|
// Regex
|
||||||
|
// ---------------------------------------------
|
||||||
|
|
||||||
|
func (this Regexs) String() string {
|
||||||
|
m := make([]string, len(this))
|
||||||
|
for k, v := range this {
|
||||||
|
m[k] = v.String()
|
||||||
|
}
|
||||||
|
return strings.Join(m, ", ")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this Regex) String() string {
|
||||||
|
return print("/%v/", this.VA)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------
|
// ---------------------------------------------
|
||||||
|
@ -669,6 +648,27 @@ func (this Batch) String() string {
|
||||||
return print("batch(%v, [%v]", this.TB, this.BA)
|
return print("batch(%v, [%v]", this.TB, this.BA)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------
|
||||||
|
// Model
|
||||||
|
// ---------------------------------------------
|
||||||
|
|
||||||
|
func (this Model) String() string {
|
||||||
|
switch {
|
||||||
|
case this.INC == 0:
|
||||||
|
max := strconv.FormatFloat(this.MAX, 'f', -1, 64)
|
||||||
|
return print("|%s:%s|", quote(this.TB), max)
|
||||||
|
case this.INC == 1:
|
||||||
|
min := strconv.FormatFloat(this.MIN, 'f', -1, 64)
|
||||||
|
max := strconv.FormatFloat(this.MAX, 'f', -1, 64)
|
||||||
|
return print("|%s:%s..%s|", quote(this.TB), min, max)
|
||||||
|
default:
|
||||||
|
inc := strconv.FormatFloat(this.INC, 'f', -1, 64)
|
||||||
|
min := strconv.FormatFloat(this.MIN, 'f', -1, 64)
|
||||||
|
max := strconv.FormatFloat(this.MAX, 'f', -1, 64)
|
||||||
|
return print("|%s:%s,%s..%s|", quote(this.TB), min, inc, max)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------
|
// ---------------------------------------------
|
||||||
// Thing
|
// Thing
|
||||||
// ---------------------------------------------
|
// ---------------------------------------------
|
||||||
|
|
|
@ -426,13 +426,6 @@ func (tok Token) precedence() int {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tok Token) String() string {
|
|
||||||
if tok >= 0 && tok < Token(len(tokens)) {
|
|
||||||
return tokens[tok]
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func newToken(s string) Token {
|
func newToken(s string) Token {
|
||||||
for k, v := range tokens {
|
for k, v := range tokens {
|
||||||
if len(v) == len(s) {
|
if len(v) == len(s) {
|
||||||
|
@ -444,6 +437,26 @@ func newToken(s string) Token {
|
||||||
return ILLEGAL
|
return ILLEGAL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tok Token) String() string {
|
||||||
|
if tok >= 0 && tok < Token(len(tokens)) {
|
||||||
|
return tokens[tok]
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this Token) MarshalText() (data []byte, err error) {
|
||||||
|
return []byte(this.String()), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this Token) MarshalBinary() (data []byte, err error) {
|
||||||
|
return []byte(this.String()), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Token) UnmarshalBinary(data []byte) (err error) {
|
||||||
|
*this = newToken(string(data))
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func (tok Token) isLiteral() bool { return tok > literalsBeg && tok < literalsEnd }
|
func (tok Token) isLiteral() bool { return tok > literalsBeg && tok < literalsEnd }
|
||||||
|
|
||||||
func (tok Token) isKeyword() bool { return tok > keywordsBeg && tok < keywordsEnd }
|
func (tok Token) isKeyword() bool { return tok > keywordsBeg && tok < keywordsEnd }
|
||||||
|
|
52
sql/util.go
52
sql/util.go
|
@ -20,7 +20,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
json "github.com/hjson/hjson-go"
|
"github.com/hjson/hjson-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
func in(token Token, tokens []Token) bool {
|
func in(token Token, tokens []Token) bool {
|
||||||
|
@ -73,44 +73,44 @@ func (p *parser) declare(tok Token, lit string) (interface{}, error) {
|
||||||
case FALSE:
|
case FALSE:
|
||||||
return false, nil
|
return false, nil
|
||||||
|
|
||||||
case NULL:
|
|
||||||
return &Null{}, nil
|
|
||||||
|
|
||||||
case VOID:
|
|
||||||
return &Void{}, nil
|
|
||||||
|
|
||||||
case MISSING:
|
|
||||||
return &Void{}, nil
|
|
||||||
|
|
||||||
case EMPTY:
|
|
||||||
return &Empty{}, nil
|
|
||||||
|
|
||||||
case MUL:
|
case MUL:
|
||||||
return &All{}, nil
|
return new(All), nil
|
||||||
|
|
||||||
case QMARK:
|
case QMARK:
|
||||||
return &Any{}, nil
|
return new(Any), nil
|
||||||
|
|
||||||
case STRING:
|
case NULL:
|
||||||
return &Value{lit}, nil
|
return new(Null), nil
|
||||||
|
|
||||||
case REGION:
|
case VOID:
|
||||||
return &Value{lit}, nil
|
return new(Void), nil
|
||||||
|
|
||||||
|
case MISSING:
|
||||||
|
return new(Void), nil
|
||||||
|
|
||||||
|
case EMPTY:
|
||||||
|
return new(Empty), nil
|
||||||
|
|
||||||
case EXPR:
|
case EXPR:
|
||||||
return &Ident{lit}, nil
|
return NewIdent(lit), nil
|
||||||
|
|
||||||
case IDENT:
|
case IDENT:
|
||||||
return &Ident{lit}, nil
|
return NewIdent(lit), nil
|
||||||
|
|
||||||
case TABLE:
|
case TABLE:
|
||||||
return &Table{lit}, nil
|
return NewTable(lit), nil
|
||||||
|
|
||||||
case PARAM:
|
case PARAM:
|
||||||
return &Param{lit}, nil
|
return NewParam(lit), nil
|
||||||
|
|
||||||
case REGEX:
|
case REGEX:
|
||||||
return &Regex{lit}, nil
|
return NewRegex(lit), nil
|
||||||
|
|
||||||
|
case STRING:
|
||||||
|
return NewValue(lit), nil
|
||||||
|
|
||||||
|
case REGION:
|
||||||
|
return NewValue(lit), nil
|
||||||
|
|
||||||
case DATE:
|
case DATE:
|
||||||
return time.Parse(RFCDate, lit)
|
return time.Parse(RFCDate, lit)
|
||||||
|
@ -150,7 +150,7 @@ func (p *parser) declare(tok Token, lit string) (interface{}, error) {
|
||||||
|
|
||||||
case ARRAY:
|
case ARRAY:
|
||||||
var j []interface{}
|
var j []interface{}
|
||||||
json.Unmarshal([]byte(lit), &j)
|
hjson.Unmarshal([]byte(lit), &j)
|
||||||
if j == nil {
|
if j == nil {
|
||||||
return j, fmt.Errorf("Invalid JSON: %s", lit)
|
return j, fmt.Errorf("Invalid JSON: %s", lit)
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ func (p *parser) declare(tok Token, lit string) (interface{}, error) {
|
||||||
|
|
||||||
case JSON:
|
case JSON:
|
||||||
var j map[string]interface{}
|
var j map[string]interface{}
|
||||||
json.Unmarshal([]byte(lit), &j)
|
hjson.Unmarshal([]byte(lit), &j)
|
||||||
if j == nil {
|
if j == nil {
|
||||||
return j, fmt.Errorf("Invalid JSON: %s", lit)
|
return j, fmt.Errorf("Invalid JSON: %s", lit)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,10 @@ import (
|
||||||
func get(ctx context.Context, args ...interface{}) (interface{}, error) {
|
func get(ctx context.Context, args ...interface{}) (interface{}, error) {
|
||||||
doc := data.Consume(args[0])
|
doc := data.Consume(args[0])
|
||||||
switch fld := args[1].(type) {
|
switch fld := args[1].(type) {
|
||||||
case *sql.Value:
|
|
||||||
return doc.Get(fld.ID).Data(), nil
|
|
||||||
case string:
|
case string:
|
||||||
return doc.Get(fld).Data(), nil
|
return doc.Get(fld).Data(), nil
|
||||||
|
case *sql.Value:
|
||||||
|
return doc.Get(fld.VA).Data(), nil
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ func Build(cols sql.Idents, item *data.Doc) (out [][]interface{}) {
|
||||||
|
|
||||||
sub := Build(cols, item)
|
sub := Build(cols, item)
|
||||||
|
|
||||||
if arr, ok := item.Get(col.ID).Data().([]interface{}); ok {
|
if arr, ok := item.Get(col.VA).Data().([]interface{}); ok {
|
||||||
for _, s := range sub {
|
for _, s := range sub {
|
||||||
for _, a := range arr {
|
for _, a := range arr {
|
||||||
idx := []interface{}{}
|
idx := []interface{}{}
|
||||||
|
@ -69,7 +69,7 @@ func Build(cols sql.Idents, item *data.Doc) (out [][]interface{}) {
|
||||||
} else {
|
} else {
|
||||||
for _, s := range sub {
|
for _, s := range sub {
|
||||||
idx := []interface{}{}
|
idx := []interface{}{}
|
||||||
idx = append(idx, item.Get(col.ID).Data())
|
idx = append(idx, item.Get(col.VA).Data())
|
||||||
idx = append(idx, s...)
|
idx = append(idx, s...)
|
||||||
out = append(out, idx)
|
out = append(out, idx)
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,7 +335,7 @@ func checkBearer(c *fibre.Context, info string, callback func() error) (err erro
|
||||||
|
|
||||||
// Store the authenticated scope.
|
// Store the authenticated scope.
|
||||||
|
|
||||||
auth.Scope = scp.Name.ID
|
auth.Scope = scp.Name.VA
|
||||||
|
|
||||||
// Store the authenticated thing.
|
// Store the authenticated thing.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue