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)
|
||||
|
||||
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)
|
||||
|
||||
case *sql.Thing:
|
||||
|
|
94
db/db.gen.go
94
db/db.gen.go
|
@ -11,23 +11,23 @@ import (
|
|||
|
||||
const (
|
||||
// ----- content types ----
|
||||
codecSelferCcUTF89003 = 1
|
||||
codecSelferCcRAW9003 = 0
|
||||
codecSelferCcUTF84219 = 1
|
||||
codecSelferCcRAW4219 = 0
|
||||
// ----- value types used ----
|
||||
codecSelferValueTypeArray9003 = 10
|
||||
codecSelferValueTypeMap9003 = 9
|
||||
codecSelferValueTypeString9003 = 6
|
||||
codecSelferValueTypeInt9003 = 2
|
||||
codecSelferValueTypeUint9003 = 3
|
||||
codecSelferValueTypeFloat9003 = 4
|
||||
codecSelferBitsize9003 = uint8(32 << (^uint(0) >> 63))
|
||||
codecSelferValueTypeArray4219 = 10
|
||||
codecSelferValueTypeMap4219 = 9
|
||||
codecSelferValueTypeString4219 = 6
|
||||
codecSelferValueTypeInt4219 = 2
|
||||
codecSelferValueTypeUint4219 = 3
|
||||
codecSelferValueTypeFloat4219 = 4
|
||||
codecSelferBitsize4219 = uint8(32 << (^uint(0) >> 63))
|
||||
)
|
||||
|
||||
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() {
|
||||
if codec1978.GenVersion != 8 {
|
||||
|
@ -39,7 +39,7 @@ func init() {
|
|||
}
|
||||
|
||||
func (x *Response) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||
var h codecSelfer9003
|
||||
var h codecSelfer4219
|
||||
z, r := codec1978.GenHelperEncoder(e)
|
||||
_, _, _ = h, z, r
|
||||
if x == nil {
|
||||
|
@ -77,19 +77,19 @@ func (x *Response) CodecEncodeSelf(e *codec1978.Encoder) {
|
|||
if yyq2[0] {
|
||||
if false {
|
||||
} else {
|
||||
r.EncodeString(codecSelferCcUTF89003, string(x.Time))
|
||||
r.EncodeString(codecSelferCcUTF84219, string(x.Time))
|
||||
}
|
||||
} else {
|
||||
r.EncodeString(codecSelferCcUTF89003, "")
|
||||
r.EncodeString(codecSelferCcUTF84219, "")
|
||||
}
|
||||
} else {
|
||||
if yyq2[0] {
|
||||
r.WriteMapElemKey()
|
||||
r.EncodeString(codecSelferCcUTF89003, `time`)
|
||||
r.EncodeString(codecSelferCcUTF84219, `time`)
|
||||
r.WriteMapElemValue()
|
||||
if false {
|
||||
} 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 false {
|
||||
} else {
|
||||
r.EncodeString(codecSelferCcUTF89003, string(x.Status))
|
||||
r.EncodeString(codecSelferCcUTF84219, string(x.Status))
|
||||
}
|
||||
} else {
|
||||
r.EncodeString(codecSelferCcUTF89003, "")
|
||||
r.EncodeString(codecSelferCcUTF84219, "")
|
||||
}
|
||||
} else {
|
||||
if yyq2[1] {
|
||||
r.WriteMapElemKey()
|
||||
r.EncodeString(codecSelferCcUTF89003, `status`)
|
||||
r.EncodeString(codecSelferCcUTF84219, `status`)
|
||||
r.WriteMapElemValue()
|
||||
if false {
|
||||
} 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 false {
|
||||
} else {
|
||||
r.EncodeString(codecSelferCcUTF89003, string(x.Detail))
|
||||
r.EncodeString(codecSelferCcUTF84219, string(x.Detail))
|
||||
}
|
||||
} else {
|
||||
r.EncodeString(codecSelferCcUTF89003, "")
|
||||
r.EncodeString(codecSelferCcUTF84219, "")
|
||||
}
|
||||
} else {
|
||||
if yyq2[2] {
|
||||
r.WriteMapElemKey()
|
||||
r.EncodeString(codecSelferCcUTF89003, `detail`)
|
||||
r.EncodeString(codecSelferCcUTF84219, `detail`)
|
||||
r.WriteMapElemValue()
|
||||
if false {
|
||||
} 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 {
|
||||
if yyq2[3] {
|
||||
r.WriteMapElemKey()
|
||||
r.EncodeString(codecSelferCcUTF89003, `result`)
|
||||
r.EncodeString(codecSelferCcUTF84219, `result`)
|
||||
r.WriteMapElemValue()
|
||||
if x.Result == nil {
|
||||
r.EncodeNil()
|
||||
|
@ -174,7 +174,7 @@ func (x *Response) CodecEncodeSelf(e *codec1978.Encoder) {
|
|||
}
|
||||
|
||||
func (x *Response) CodecDecodeSelf(d *codec1978.Decoder) {
|
||||
var h codecSelfer9003
|
||||
var h codecSelfer4219
|
||||
z, r := codec1978.GenHelperDecoder(d)
|
||||
_, _, _ = h, z, r
|
||||
if false {
|
||||
|
@ -182,14 +182,14 @@ func (x *Response) CodecDecodeSelf(d *codec1978.Decoder) {
|
|||
z.DecExtension(x, yyxt1)
|
||||
} else {
|
||||
yyct2 := r.ContainerType()
|
||||
if yyct2 == codecSelferValueTypeMap9003 {
|
||||
if yyct2 == codecSelferValueTypeMap4219 {
|
||||
yyl2 := r.ReadMapStart()
|
||||
if yyl2 == 0 {
|
||||
r.ReadMapEnd()
|
||||
} else {
|
||||
x.codecDecodeSelfFromMap(yyl2, d)
|
||||
}
|
||||
} else if yyct2 == codecSelferValueTypeArray9003 {
|
||||
} else if yyct2 == codecSelferValueTypeArray4219 {
|
||||
yyl2 := r.ReadArrayStart()
|
||||
if yyl2 == 0 {
|
||||
r.ReadArrayEnd()
|
||||
|
@ -197,13 +197,13 @@ func (x *Response) CodecDecodeSelf(d *codec1978.Decoder) {
|
|||
x.codecDecodeSelfFromArray(yyl2, d)
|
||||
}
|
||||
} else {
|
||||
panic(errCodecSelferOnlyMapOrArrayEncodeToStruct9003)
|
||||
panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4219)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Response) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
|
||||
var h codecSelfer9003
|
||||
var h codecSelfer4219
|
||||
z, r := codec1978.GenHelperDecoder(d)
|
||||
_, _, _ = h, z, r
|
||||
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) {
|
||||
var h codecSelfer9003
|
||||
var h codecSelfer4219
|
||||
z, r := codec1978.GenHelperDecoder(d)
|
||||
_, _, _ = h, z, r
|
||||
var yyj9 int
|
||||
|
@ -346,7 +346,7 @@ func (x *Response) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
|
|||
}
|
||||
|
||||
func (x *Dispatch) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||
var h codecSelfer9003
|
||||
var h codecSelfer4219
|
||||
z, r := codec1978.GenHelperEncoder(e)
|
||||
_, _, _ = h, z, r
|
||||
if x == nil {
|
||||
|
@ -383,19 +383,19 @@ func (x *Dispatch) CodecEncodeSelf(e *codec1978.Encoder) {
|
|||
if yyq2[0] {
|
||||
if false {
|
||||
} else {
|
||||
r.EncodeString(codecSelferCcUTF89003, string(x.Query))
|
||||
r.EncodeString(codecSelferCcUTF84219, string(x.Query))
|
||||
}
|
||||
} else {
|
||||
r.EncodeString(codecSelferCcUTF89003, "")
|
||||
r.EncodeString(codecSelferCcUTF84219, "")
|
||||
}
|
||||
} else {
|
||||
if yyq2[0] {
|
||||
r.WriteMapElemKey()
|
||||
r.EncodeString(codecSelferCcUTF89003, `query`)
|
||||
r.EncodeString(codecSelferCcUTF84219, `query`)
|
||||
r.WriteMapElemValue()
|
||||
if false {
|
||||
} 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 false {
|
||||
} else {
|
||||
r.EncodeString(codecSelferCcUTF89003, string(x.Action))
|
||||
r.EncodeString(codecSelferCcUTF84219, string(x.Action))
|
||||
}
|
||||
} else {
|
||||
r.EncodeString(codecSelferCcUTF89003, "")
|
||||
r.EncodeString(codecSelferCcUTF84219, "")
|
||||
}
|
||||
} else {
|
||||
if yyq2[1] {
|
||||
r.WriteMapElemKey()
|
||||
r.EncodeString(codecSelferCcUTF89003, `action`)
|
||||
r.EncodeString(codecSelferCcUTF84219, `action`)
|
||||
r.WriteMapElemValue()
|
||||
if false {
|
||||
} 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 {
|
||||
if yyq2[2] {
|
||||
r.WriteMapElemKey()
|
||||
r.EncodeString(codecSelferCcUTF89003, `result`)
|
||||
r.EncodeString(codecSelferCcUTF84219, `result`)
|
||||
r.WriteMapElemValue()
|
||||
if x.Result == nil {
|
||||
r.EncodeNil()
|
||||
|
@ -459,7 +459,7 @@ func (x *Dispatch) CodecEncodeSelf(e *codec1978.Encoder) {
|
|||
}
|
||||
|
||||
func (x *Dispatch) CodecDecodeSelf(d *codec1978.Decoder) {
|
||||
var h codecSelfer9003
|
||||
var h codecSelfer4219
|
||||
z, r := codec1978.GenHelperDecoder(d)
|
||||
_, _, _ = h, z, r
|
||||
if false {
|
||||
|
@ -467,14 +467,14 @@ func (x *Dispatch) CodecDecodeSelf(d *codec1978.Decoder) {
|
|||
z.DecExtension(x, yyxt1)
|
||||
} else {
|
||||
yyct2 := r.ContainerType()
|
||||
if yyct2 == codecSelferValueTypeMap9003 {
|
||||
if yyct2 == codecSelferValueTypeMap4219 {
|
||||
yyl2 := r.ReadMapStart()
|
||||
if yyl2 == 0 {
|
||||
r.ReadMapEnd()
|
||||
} else {
|
||||
x.codecDecodeSelfFromMap(yyl2, d)
|
||||
}
|
||||
} else if yyct2 == codecSelferValueTypeArray9003 {
|
||||
} else if yyct2 == codecSelferValueTypeArray4219 {
|
||||
yyl2 := r.ReadArrayStart()
|
||||
if yyl2 == 0 {
|
||||
r.ReadArrayEnd()
|
||||
|
@ -482,13 +482,13 @@ func (x *Dispatch) CodecDecodeSelf(d *codec1978.Decoder) {
|
|||
x.codecDecodeSelfFromArray(yyl2, d)
|
||||
}
|
||||
} else {
|
||||
panic(errCodecSelferOnlyMapOrArrayEncodeToStruct9003)
|
||||
panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4219)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Dispatch) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
|
||||
var h codecSelfer9003
|
||||
var h codecSelfer4219
|
||||
z, r := codec1978.GenHelperDecoder(d)
|
||||
_, _, _ = h, z, r
|
||||
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) {
|
||||
var h codecSelfer9003
|
||||
var h codecSelfer4219
|
||||
z, r := codec1978.GenHelperDecoder(d)
|
||||
_, _, _ = h, z, r
|
||||
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) {
|
||||
|
||||
// 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())
|
||||
|
||||
return
|
||||
|
@ -39,7 +39,7 @@ func (e *executor) executeDefineDatabase(ctx context.Context, ast *sql.DefineDat
|
|||
e.dbo.AddNS(ctx, ast.NS)
|
||||
|
||||
// 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())
|
||||
|
||||
return
|
||||
|
@ -58,7 +58,7 @@ func (e *executor) executeDefineLogin(ctx context.Context, ast *sql.DefineLoginS
|
|||
e.dbo.AddNS(ctx, ast.NS)
|
||||
|
||||
// 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())
|
||||
|
||||
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)
|
||||
|
||||
// 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())
|
||||
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ func (e *executor) executeDefineToken(ctx context.Context, ast *sql.DefineTokenS
|
|||
e.dbo.AddNS(ctx, ast.NS)
|
||||
|
||||
// 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())
|
||||
|
||||
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)
|
||||
|
||||
// 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())
|
||||
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ func (e *executor) executeDefineScope(ctx context.Context, ast *sql.DefineScopeS
|
|||
e.dbo.AddDB(ctx, ast.NS, ast.DB)
|
||||
|
||||
// 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())
|
||||
|
||||
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)
|
||||
|
||||
// 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 {
|
||||
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)
|
||||
|
||||
// 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 {
|
||||
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)
|
||||
|
||||
// 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 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ func (e *executor) executeDelete(ctx context.Context, stm *sql.DeleteStatement)
|
|||
i.processTable(ctx, key)
|
||||
|
||||
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)
|
||||
|
||||
case *sql.Thing:
|
||||
|
|
|
@ -32,7 +32,6 @@ type document struct {
|
|||
ns string
|
||||
db string
|
||||
tb string
|
||||
md map[string]interface{}
|
||||
id *sql.Thing
|
||||
key *keys.Thing
|
||||
val kvs.KV
|
||||
|
@ -449,11 +448,11 @@ func (d *document) storeIndex(ctx context.Context) (err error) {
|
|||
|
||||
if ix.Uniq == true {
|
||||
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())
|
||||
}
|
||||
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 {
|
||||
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 {
|
||||
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())
|
||||
}
|
||||
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 {
|
||||
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 {
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
||||
if ix.Uniq == false {
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
|
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
|
||||
case *sql.Null:
|
||||
return nil, nil
|
||||
case *sql.Thing:
|
||||
return val, nil
|
||||
case *sql.Value:
|
||||
return val.ID, nil
|
||||
return val.VA, nil
|
||||
case int:
|
||||
return float64(val), nil
|
||||
case int8:
|
||||
return float64(val), nil
|
||||
case int16:
|
||||
return float64(val), nil
|
||||
case int32:
|
||||
return float64(val), nil
|
||||
case int64:
|
||||
return float64(val), nil
|
||||
case uint:
|
||||
case float64:
|
||||
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{}:
|
||||
return deep.Copy(val), nil
|
||||
case map[string]interface{}:
|
||||
|
@ -73,7 +57,7 @@ func (e *executor) fetch(ctx context.Context, val interface{}, doc *data.Doc) (o
|
|||
|
||||
case *sql.Regex:
|
||||
|
||||
return regexp.Compile(val.ID)
|
||||
return regexp.Compile(val.VA)
|
||||
|
||||
case *sql.Ident:
|
||||
|
||||
|
@ -98,7 +82,7 @@ func (e *executor) fetch(ctx context.Context, val interface{}, doc *data.Doc) (o
|
|||
return val
|
||||
}
|
||||
|
||||
res := doc.Fetch(fnc, val.ID).Data()
|
||||
res := doc.Fetch(fnc, val.VA).Data()
|
||||
|
||||
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:
|
||||
|
||||
if len(val.ID) > 0 {
|
||||
if len(val.VA) > 0 {
|
||||
|
||||
for _, s := range paramSearchKeys {
|
||||
|
||||
|
@ -126,7 +110,7 @@ func (e *executor) fetch(ctx context.Context, val interface{}, doc *data.Doc) (o
|
|||
return val
|
||||
}
|
||||
|
||||
res := obj.Fetch(fnc, val.ID).Data()
|
||||
res := obj.Fetch(fnc, val.VA).Data()
|
||||
|
||||
if res != nil {
|
||||
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 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) {
|
||||
case *sql.Ident:
|
||||
if op == sql.EQ {
|
||||
return d.Exists(r.ID) == false
|
||||
return d.Exists(r.VA) == false
|
||||
} else if op == sql.NEQ {
|
||||
return d.Exists(r.ID) == true
|
||||
return d.Exists(r.VA) == true
|
||||
}
|
||||
}
|
||||
case *sql.Null:
|
||||
switch r := ro.(type) {
|
||||
case *sql.Ident:
|
||||
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 {
|
||||
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) {
|
||||
case *sql.Ident:
|
||||
if op == sql.EQ {
|
||||
return d.Exists(l.ID) == false
|
||||
return d.Exists(l.VA) == false
|
||||
} else if op == sql.NEQ {
|
||||
return d.Exists(l.ID) == true
|
||||
return d.Exists(l.VA) == true
|
||||
}
|
||||
}
|
||||
case *sql.Null:
|
||||
switch l := lo.(type) {
|
||||
case *sql.Ident:
|
||||
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 {
|
||||
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{})
|
||||
for _, v := range db {
|
||||
dbase[v.Name.ID] = v.String()
|
||||
dbase[v.Name.VA] = v.String()
|
||||
}
|
||||
|
||||
token := make(map[string]interface{})
|
||||
for _, v := range nt {
|
||||
token[v.Name.ID] = v.String()
|
||||
token[v.Name.VA] = v.String()
|
||||
}
|
||||
|
||||
login := make(map[string]interface{})
|
||||
for _, v := range nu {
|
||||
login[v.User.ID] = v.String()
|
||||
login[v.User.VA] = v.String()
|
||||
}
|
||||
|
||||
res.Set(dbase, "database")
|
||||
|
@ -104,22 +104,22 @@ func (e *executor) executeInfoDB(ctx context.Context, ast *sql.InfoStatement) (o
|
|||
|
||||
table := make(map[string]interface{})
|
||||
for _, v := range tb {
|
||||
table[v.Name.ID] = v.String()
|
||||
table[v.Name.VA] = v.String()
|
||||
}
|
||||
|
||||
token := make(map[string]interface{})
|
||||
for _, v := range dt {
|
||||
token[v.Name.ID] = v.String()
|
||||
token[v.Name.VA] = v.String()
|
||||
}
|
||||
|
||||
login := make(map[string]interface{})
|
||||
for _, v := range du {
|
||||
login[v.User.ID] = v.String()
|
||||
login[v.User.VA] = v.String()
|
||||
}
|
||||
|
||||
scope := make(map[string]interface{})
|
||||
for _, v := range sc {
|
||||
scope[v.Name.ID] = v.String()
|
||||
scope[v.Name.VA] = v.String()
|
||||
}
|
||||
|
||||
res.Set(table, "table")
|
||||
|
@ -157,22 +157,22 @@ func (e *executor) executeInfoTB(ctx context.Context, ast *sql.InfoStatement) (o
|
|||
|
||||
event := make(map[string]interface{})
|
||||
for _, v := range ev {
|
||||
event[v.Name.ID] = v.String()
|
||||
event[v.Name.VA] = v.String()
|
||||
}
|
||||
|
||||
field := make(map[string]interface{})
|
||||
for _, v := range fd {
|
||||
field[v.Name.ID] = v.String()
|
||||
field[v.Name.VA] = v.String()
|
||||
}
|
||||
|
||||
index := make(map[string]interface{})
|
||||
for _, v := range ix {
|
||||
index[v.Name.ID] = v.String()
|
||||
index[v.Name.VA] = v.String()
|
||||
}
|
||||
|
||||
table := make(map[string]interface{})
|
||||
for _, v := range ft {
|
||||
table[v.Name.ID] = v.String()
|
||||
table[v.Name.VA] = v.String()
|
||||
}
|
||||
|
||||
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 {
|
||||
switch i.stm.(type) {
|
||||
case *sql.CreateStatement:
|
||||
i.err = &TableError{table: tb.Name.ID}
|
||||
i.err = &TableError{table: tb.Name.VA}
|
||||
case *sql.UpdateStatement:
|
||||
i.err = &TableError{table: tb.Name.ID}
|
||||
i.err = &TableError{table: tb.Name.VA}
|
||||
case *sql.DeleteStatement:
|
||||
i.err = &TableError{table: tb.Name.ID}
|
||||
i.err = &TableError{table: tb.Name.VA}
|
||||
case *sql.RelateStatement:
|
||||
i.err = &TableError{table: tb.Name.ID}
|
||||
i.err = &TableError{table: tb.Name.VA}
|
||||
case *sql.InsertStatement:
|
||||
i.err = &TableError{table: tb.Name.ID}
|
||||
i.err = &TableError{table: tb.Name.VA}
|
||||
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 {
|
||||
switch i.stm.(type) {
|
||||
case *sql.CreateStatement:
|
||||
i.err = &TableError{table: tb.Name.ID}
|
||||
i.err = &TableError{table: tb.Name.VA}
|
||||
case *sql.UpdateStatement:
|
||||
i.err = &TableError{table: tb.Name.ID}
|
||||
i.err = &TableError{table: tb.Name.VA}
|
||||
case *sql.DeleteStatement:
|
||||
i.err = &TableError{table: tb.Name.ID}
|
||||
i.err = &TableError{table: tb.Name.VA}
|
||||
case *sql.RelateStatement:
|
||||
i.err = &TableError{table: tb.Name.ID}
|
||||
i.err = &TableError{table: tb.Name.VA}
|
||||
case *sql.InsertStatement:
|
||||
i.err = &TableError{table: tb.Name.ID}
|
||||
i.err = &TableError{table: tb.Name.VA}
|
||||
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) {
|
||||
default:
|
||||
i.err = &PermsError{table: tb.Name.ID}
|
||||
i.err = &PermsError{table: tb.Name.VA}
|
||||
case *sql.PermExpression:
|
||||
switch i.stm.(type) {
|
||||
case *sql.SelectStatement:
|
||||
|
|
|
@ -27,15 +27,15 @@ func (e *executor) executeLet(ctx context.Context, stm *sql.LetStatement) (out [
|
|||
|
||||
switch what := stm.What.(type) {
|
||||
case *sql.Void:
|
||||
vars.Del(stm.Name.ID)
|
||||
vars.Del(stm.Name.VA)
|
||||
case *sql.Empty:
|
||||
vars.Del(stm.Name.ID)
|
||||
vars.Del(stm.Name.VA)
|
||||
default:
|
||||
val, err := e.fetch(ctx, what, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
vars.Set(val, stm.Name.ID)
|
||||
vars.Set(val, stm.Name.VA)
|
||||
}
|
||||
|
||||
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) {
|
||||
keys[key] = struct{}{}
|
||||
return
|
||||
}, fd.Name.ID)
|
||||
}, fd.Name.VA)
|
||||
}
|
||||
|
||||
// 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:
|
||||
switch n.(type) {
|
||||
default:
|
||||
d.current.Set(n, i.ID)
|
||||
d.current.Set(n, i.VA)
|
||||
case *sql.Void:
|
||||
d.current.Del(i.ID)
|
||||
d.current.Del(i.VA)
|
||||
}
|
||||
case sql.INC:
|
||||
d.current.Inc(n, i.ID)
|
||||
d.current.Inc(n, i.VA)
|
||||
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
|
||||
// for a 'datetime' and 'record'.
|
||||
|
||||
// IMPORTANT remove this, and put it in SQL parser
|
||||
|
||||
d.current.Each(func(key string, val interface{}) (err error) {
|
||||
if val, ok := conv.MightBe(val); ok {
|
||||
d.current.Iff(val, key)
|
||||
|
@ -423,7 +425,7 @@ func (d *document) mrgFld(ctx context.Context, met method) (err error) {
|
|||
|
||||
return nil
|
||||
|
||||
}, fd.Name.ID)
|
||||
}, fd.Name.VA)
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
|
|
|
@ -88,7 +88,7 @@ func (d *document) perms(ctx context.Context, doc *data.Doc) (err error) {
|
|||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
// 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) {
|
||||
|
||||
e.dbo.DelNS(ast.Name.ID)
|
||||
e.dbo.DelNS(ast.Name.VA)
|
||||
|
||||
// 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())
|
||||
|
||||
// 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)
|
||||
|
||||
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) {
|
||||
|
||||
e.dbo.DelDB(ast.NS, ast.Name.ID)
|
||||
e.dbo.DelDB(ast.NS, ast.Name.VA)
|
||||
|
||||
// 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())
|
||||
|
||||
// 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)
|
||||
|
||||
return
|
||||
|
@ -59,13 +59,13 @@ func (e *executor) executeRemoveLogin(ctx context.Context, ast *sql.RemoveLoginS
|
|||
case sql.NAMESPACE:
|
||||
|
||||
// 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)
|
||||
|
||||
case sql.DATABASE:
|
||||
|
||||
// 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)
|
||||
|
||||
}
|
||||
|
@ -80,13 +80,13 @@ func (e *executor) executeRemoveToken(ctx context.Context, ast *sql.RemoveTokenS
|
|||
case sql.NAMESPACE:
|
||||
|
||||
// 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)
|
||||
|
||||
case sql.DATABASE:
|
||||
|
||||
// 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)
|
||||
|
||||
}
|
||||
|
@ -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) {
|
||||
|
||||
// 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)
|
||||
|
||||
return
|
||||
|
@ -109,10 +109,10 @@ func (e *executor) executeRemoveEvent(ctx context.Context, ast *sql.RemoveEventS
|
|||
|
||||
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
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -127,10 +127,10 @@ func (e *executor) executeRemoveField(ctx context.Context, ast *sql.RemoveFieldS
|
|||
|
||||
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
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -145,16 +145,16 @@ func (e *executor) executeRemoveIndex(ctx context.Context, ast *sql.RemoveIndexS
|
|||
|
||||
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
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ func (e *executor) executeSelect(ctx context.Context, stm *sql.SelectStatement)
|
|||
i.processTable(ctx, key)
|
||||
|
||||
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)
|
||||
|
||||
case *sql.Thing:
|
||||
|
|
|
@ -212,7 +212,7 @@ func (s *socket) deregister(id string) {
|
|||
|
||||
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())
|
||||
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ func (s *socket) executeLive(e *executor, ctx context.Context, stm *sql.LiveStat
|
|||
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 {
|
||||
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())
|
||||
|
||||
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())
|
||||
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
prv = sql.NewThing(ft.Name.ID, fmt.Sprintf("%v", old))
|
||||
doc = sql.NewThing(ft.Name.ID, fmt.Sprintf("%v", now))
|
||||
prv = sql.NewThing(ft.Name.VA, fmt.Sprintf("%v", old))
|
||||
doc = sql.NewThing(ft.Name.VA, fmt.Sprintf("%v", now))
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -85,7 +85,7 @@ func (d *document) table(ctx context.Context, when method) (err error) {
|
|||
// current record as the basis of the
|
||||
// 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)
|
||||
|
||||
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)
|
||||
|
||||
case *sql.Thing:
|
||||
|
|
|
@ -263,7 +263,7 @@ func (d *document) yield(ctx context.Context, stm sql.Statement, output sql.Toke
|
|||
|
||||
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.
|
||||
type UseStatement struct {
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
NS string
|
||||
DB string
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
|
@ -82,11 +82,11 @@ type UseStatement struct {
|
|||
|
||||
// InfoStatement represents an SQL INFO statement.
|
||||
type InfoStatement struct {
|
||||
KV string `cork:"-" codec:"-"`
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
Kind Token `cork:"-" codec:"-"`
|
||||
What *Table `cork:"-" codec:"-"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Kind Token
|
||||
What *Table
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
|
@ -95,10 +95,10 @@ type InfoStatement struct {
|
|||
|
||||
// IfStatement represents an if else clause.
|
||||
type IfStatement struct {
|
||||
RW bool `cork:"-" codec:"-"`
|
||||
Cond Exprs `cork:"cond" codec:"cond"`
|
||||
Then Exprs `cork:"then" codec:"then"`
|
||||
Else Expr `cork:"else" codec:"else"`
|
||||
RW bool
|
||||
Cond Exprs
|
||||
Then Exprs
|
||||
Else Expr
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
|
@ -107,8 +107,8 @@ type IfStatement struct {
|
|||
|
||||
// RunStatement represents a run clause.
|
||||
type RunStatement struct {
|
||||
RW bool `cork:"-" codec:"-"`
|
||||
Expr Expr `cork:"expr" codec:"expr"`
|
||||
RW bool
|
||||
Expr Expr
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
|
@ -117,21 +117,21 @@ type RunStatement struct {
|
|||
|
||||
// LetStatement represents a SQL LET statement.
|
||||
type LetStatement struct {
|
||||
RW bool `cork:"-" codec:"-"`
|
||||
KV string `cork:"-" codec:"-"`
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
Name *Ident `cork:"-" codec:"-"`
|
||||
What Expr `cork:"-" codec:"-"`
|
||||
RW bool
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Name *Ident
|
||||
What Expr
|
||||
}
|
||||
|
||||
// ReturnStatement represents a SQL RETURN statement.
|
||||
type ReturnStatement struct {
|
||||
RW bool `cork:"-" codec:"-"`
|
||||
KV string `cork:"-" codec:"-"`
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
What Exprs `cork:"-" codec:"-"`
|
||||
RW bool
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
What Exprs
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
|
@ -140,121 +140,121 @@ type ReturnStatement struct {
|
|||
|
||||
// LiveStatement represents a SQL LIVE statement.
|
||||
type LiveStatement struct {
|
||||
ID string `cork:"ID" codec:"ID"`
|
||||
FB string `cork:"FB" codec:"FB"`
|
||||
KV string `cork:"KV" codec:"KV"`
|
||||
NS string `cork:"NS" codec:"NS"`
|
||||
DB string `cork:"DB" codec:"DB"`
|
||||
Diff bool `cork:"diff" codec:"diff"`
|
||||
Expr Fields `cork:"expr" codec:"expr"`
|
||||
What Exprs `cork:"what" codec:"what"`
|
||||
Cond Expr `cork:"cond" codec:"cond"`
|
||||
Fetch Fetchs `cork:"fetch" codec:"fetch"`
|
||||
ID string
|
||||
FB string
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Diff bool
|
||||
Expr Fields
|
||||
What Exprs
|
||||
Cond Expr
|
||||
Fetch Fetchs
|
||||
}
|
||||
|
||||
// KillStatement represents a SQL KILL statement.
|
||||
type KillStatement struct {
|
||||
FB string `cork:"FB" codec:"FB"`
|
||||
KV string `cork:"KV" codec:"KV"`
|
||||
NS string `cork:"NS" codec:"NS"`
|
||||
DB string `cork:"DB" codec:"DB"`
|
||||
What Exprs `cork:"what" codec:"what"`
|
||||
FB string
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
What Exprs
|
||||
}
|
||||
|
||||
// SelectStatement represents a SQL SELECT statement.
|
||||
type SelectStatement struct {
|
||||
RW bool `cork:"-" codec:"-"`
|
||||
KV string `cork:"KV" codec:"KV"`
|
||||
NS string `cork:"NS" codec:"NS"`
|
||||
DB string `cork:"DB" codec:"DB"`
|
||||
Expr Fields `cork:"expr" codec:"expr"`
|
||||
What Exprs `cork:"what" codec:"what"`
|
||||
Cond Expr `cork:"cond" codec:"cond"`
|
||||
Group Groups `cork:"group" codec:"group"`
|
||||
Order Orders `cork:"order" codec:"order"`
|
||||
Limit Expr `cork:"limit" codec:"limit"`
|
||||
Start Expr `cork:"start" codec:"start"`
|
||||
Fetch Fetchs `cork:"fetch" codec:"fetch"`
|
||||
Version Expr `cork:"version" codec:"version"`
|
||||
Timeout time.Duration `cork:"timeout" codec:"timeout"`
|
||||
Parallel int `cork:"parallel" codec:"parallel"`
|
||||
RW bool
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Expr Fields
|
||||
What Exprs
|
||||
Cond Expr
|
||||
Group Groups
|
||||
Order Orders
|
||||
Limit Expr
|
||||
Start Expr
|
||||
Fetch Fetchs
|
||||
Version Expr
|
||||
Timeout time.Duration
|
||||
Parallel int
|
||||
}
|
||||
|
||||
// CreateStatement represents a SQL CREATE statement.
|
||||
type CreateStatement struct {
|
||||
KV string `cork:"KV" codec:"KV"`
|
||||
NS string `cork:"NS" codec:"NS"`
|
||||
DB string `cork:"DB" codec:"DB"`
|
||||
What Exprs `cork:"what" codec:"what"`
|
||||
Data Expr `cork:"data" codec:"data"`
|
||||
Echo Token `cork:"echo" codec:"echo"`
|
||||
Timeout time.Duration `cork:"timeout" codec:"timeout"`
|
||||
Parallel int `cork:"parallel" codec:"parallel"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
What Exprs
|
||||
Data Expr
|
||||
Echo Token
|
||||
Timeout time.Duration
|
||||
Parallel int
|
||||
}
|
||||
|
||||
// UpdateStatement represents a SQL UPDATE statement.
|
||||
type UpdateStatement struct {
|
||||
KV string `cork:"KV" codec:"KV"`
|
||||
NS string `cork:"NS" codec:"NS"`
|
||||
DB string `cork:"DB" codec:"DB"`
|
||||
What Exprs `cork:"what" codec:"what"`
|
||||
Data Expr `cork:"data" codec:"data"`
|
||||
Cond Expr `cork:"cond" codec:"cond"`
|
||||
Echo Token `cork:"echo" codec:"echo"`
|
||||
Timeout time.Duration `cork:"timeout" codec:"timeout"`
|
||||
Parallel int `cork:"parallel" codec:"parallel"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
What Exprs
|
||||
Data Expr
|
||||
Cond Expr
|
||||
Echo Token
|
||||
Timeout time.Duration
|
||||
Parallel int
|
||||
}
|
||||
|
||||
// DeleteStatement represents a SQL DELETE statement.
|
||||
type DeleteStatement struct {
|
||||
KV string `cork:"KV" codec:"KV"`
|
||||
NS string `cork:"NS" codec:"NS"`
|
||||
DB string `cork:"DB" codec:"DB"`
|
||||
Hard bool `cork:"hard" codec:"hard"`
|
||||
What Exprs `cork:"what" codec:"what"`
|
||||
Cond Expr `cork:"cond" codec:"cond"`
|
||||
Echo Token `cork:"echo" codec:"echo"`
|
||||
Timeout time.Duration `cork:"timeout" codec:"timeout"`
|
||||
Parallel int `cork:"parallel" codec:"parallel"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Hard bool
|
||||
What Exprs
|
||||
Cond Expr
|
||||
Echo Token
|
||||
Timeout time.Duration
|
||||
Parallel int
|
||||
}
|
||||
|
||||
// RelateStatement represents a SQL RELATE statement.
|
||||
type RelateStatement struct {
|
||||
KV string `cork:"KV" codec:"KV"`
|
||||
NS string `cork:"NS" codec:"NS"`
|
||||
DB string `cork:"DB" codec:"DB"`
|
||||
Type Expr `cork:"type" codec:"type"`
|
||||
From Exprs `cork:"from" codec:"from"`
|
||||
With Exprs `cork:"with" codec:"with"`
|
||||
Data Expr `cork:"data" codec:"data"`
|
||||
Uniq bool `cork:"uniq" codec:"uniq"`
|
||||
Echo Token `cork:"echo" codec:"echo"`
|
||||
Timeout time.Duration `cork:"timeout" codec:"timeout"`
|
||||
Parallel int `cork:"parallel" codec:"parallel"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Type Expr
|
||||
From Exprs
|
||||
With Exprs
|
||||
Data Expr
|
||||
Uniq bool
|
||||
Echo Token
|
||||
Timeout time.Duration
|
||||
Parallel int
|
||||
}
|
||||
|
||||
// InsertStatement represents a SQL INSERT statement.
|
||||
type InsertStatement struct {
|
||||
KV string `cork:"KV" codec:"KV"`
|
||||
NS string `cork:"NS" codec:"NS"`
|
||||
DB string `cork:"DB" codec:"DB"`
|
||||
Data Expr `cork:"data" codec:"data"`
|
||||
Into *Table `cork:"into" codec:"into"`
|
||||
Echo Token `cork:"echo" codec:"echo"`
|
||||
Timeout time.Duration `cork:"timeout" codec:"timeout"`
|
||||
Parallel int `cork:"parallel" codec:"parallel"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Data Expr
|
||||
Into *Table
|
||||
Echo Token
|
||||
Timeout time.Duration
|
||||
Parallel int
|
||||
}
|
||||
|
||||
// UpsertStatement represents a SQL UPSERT statement.
|
||||
type UpsertStatement struct {
|
||||
KV string `cork:"KV" codec:"KV"`
|
||||
NS string `cork:"NS" codec:"NS"`
|
||||
DB string `cork:"DB" codec:"DB"`
|
||||
Data Expr `cork:"data" codec:"data"`
|
||||
Into *Table `cork:"into" codec:"into"`
|
||||
Echo Token `cork:"echo" codec:"echo"`
|
||||
Timeout time.Duration `cork:"timeout" codec:"timeout"`
|
||||
Parallel int `cork:"parallel" codec:"parallel"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Data Expr
|
||||
Into *Table
|
||||
Echo Token
|
||||
Timeout time.Duration
|
||||
Parallel int
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
|
@ -262,17 +262,17 @@ type UpsertStatement struct {
|
|||
// --------------------------------------------------
|
||||
|
||||
type DefineNamespaceStatement struct {
|
||||
KV string `cork:"-" codec:"-"`
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
Name *Ident `cork:"name" codec:"name"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Name *Ident
|
||||
}
|
||||
|
||||
type RemoveNamespaceStatement struct {
|
||||
KV string `cork:"-" codec:"-"`
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
Name *Ident `cork:"name" codec:"name"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Name *Ident
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
|
@ -280,17 +280,17 @@ type RemoveNamespaceStatement struct {
|
|||
// --------------------------------------------------
|
||||
|
||||
type DefineDatabaseStatement struct {
|
||||
KV string `cork:"-" codec:"-"`
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
Name *Ident `cork:"name" codec:"name"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Name *Ident
|
||||
}
|
||||
|
||||
type RemoveDatabaseStatement struct {
|
||||
KV string `cork:"-" codec:"-"`
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
Name *Ident `cork:"name" codec:"name"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Name *Ident
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
|
@ -299,22 +299,22 @@ type RemoveDatabaseStatement struct {
|
|||
|
||||
// DefineLoginStatement represents an SQL DEFINE LOGIN statement.
|
||||
type DefineLoginStatement struct {
|
||||
KV string `cork:"-" codec:"-"`
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
Kind Token `cork:"kind" codec:"kind"`
|
||||
User *Ident `cork:"user" codec:"user"`
|
||||
Pass []byte `cork:"pass" codec:"pass"`
|
||||
Code []byte `cork:"code" codec:"code"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Kind Token
|
||||
User *Ident
|
||||
Pass []byte
|
||||
Code []byte
|
||||
}
|
||||
|
||||
// RemoveLoginStatement represents an SQL REMOVE LOGIN statement.
|
||||
type RemoveLoginStatement struct {
|
||||
KV string `cork:"-" codec:"-"`
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
Kind Token `cork:"kind" codec:"kind"`
|
||||
User *Ident `cork:"user" codec:"user"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Kind Token
|
||||
User *Ident
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
|
@ -323,22 +323,22 @@ type RemoveLoginStatement struct {
|
|||
|
||||
// DefineTokenStatement represents an SQL DEFINE TOKEN statement.
|
||||
type DefineTokenStatement struct {
|
||||
KV string `cork:"-" codec:"-"`
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
Kind Token `cork:"kind" codec:"kind"`
|
||||
Name *Ident `cork:"name" codec:"name"`
|
||||
Type string `cork:"type" codec:"type"`
|
||||
Code []byte `cork:"code" codec:"code"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Kind Token
|
||||
Name *Ident
|
||||
Type string
|
||||
Code []byte
|
||||
}
|
||||
|
||||
// RemoveTokenStatement represents an SQL REMOVE TOKEN statement.
|
||||
type RemoveTokenStatement struct {
|
||||
KV string `cork:"-" codec:"-"`
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
Kind Token `cork:"kind" codec:"kind"`
|
||||
Name *Ident `cork:"name" codec:"name"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Kind Token
|
||||
Name *Ident
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
|
@ -347,25 +347,25 @@ type RemoveTokenStatement struct {
|
|||
|
||||
// DefineScopeStatement represents an SQL DEFINE SCOPE statement.
|
||||
type DefineScopeStatement struct {
|
||||
KV string `cork:"-" codec:"-"`
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
Name *Ident `cork:"name" codec:"name"`
|
||||
Time time.Duration `cork:"time" codec:"time"`
|
||||
Code []byte `cork:"code" codec:"code"`
|
||||
Signup Expr `cork:"signup" codec:"signup"`
|
||||
Signin Expr `cork:"signin" codec:"signin"`
|
||||
Connect Expr `cork:"connect" codec:"connect"`
|
||||
OnSignup Expr `cork:"onsignup" codec:"onsignup"`
|
||||
OnSignin Expr `cork:"onsignin" codec:"onsignin"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Name *Ident
|
||||
Time time.Duration
|
||||
Code []byte
|
||||
Signup Expr
|
||||
Signin Expr
|
||||
Connect Expr
|
||||
OnSignup Expr
|
||||
OnSignin Expr
|
||||
}
|
||||
|
||||
// RemoveScopeStatement represents an SQL REMOVE SCOPE statement.
|
||||
type RemoveScopeStatement struct {
|
||||
KV string `cork:"-" codec:"-"`
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
Name *Ident `cork:"name" codec:"name"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Name *Ident
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
|
@ -374,27 +374,28 @@ type RemoveScopeStatement struct {
|
|||
|
||||
// DefineTableStatement represents an SQL DEFINE TABLE statement.
|
||||
type DefineTableStatement struct {
|
||||
KV string `cork:"-" codec:"-"`
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
Name *Ident `cork:"name" codec:"name"`
|
||||
What Tables `cork:"-" codec:"-"`
|
||||
Full bool `cork:"full" codec:"full"`
|
||||
Drop bool `cork:"drop" codec:"drop"`
|
||||
Lock bool `cork:"lock" codec:"lock"`
|
||||
Expr Fields `cork:"expr" codec:"expr"`
|
||||
From Tables `cork:"from" codec:"from"`
|
||||
Cond Expr `cork:"cond" codec:"cond"`
|
||||
Group Groups `cork:"group" codec:"group"`
|
||||
Perms Expr `cork:"perms" codec:"perms"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Name *Ident
|
||||
What Tables
|
||||
Full bool
|
||||
Vers bool
|
||||
Drop bool
|
||||
Lock bool
|
||||
Expr Fields
|
||||
From Tables
|
||||
Cond Expr
|
||||
Group Groups
|
||||
Perms Expr
|
||||
}
|
||||
|
||||
// RemoveTableStatement represents an SQL REMOVE TABLE statement.
|
||||
type RemoveTableStatement struct {
|
||||
KV string `cork:"-" codec:"-"`
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
What Tables `cork:"-" codec:"-"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
What Tables
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
|
@ -403,22 +404,22 @@ type RemoveTableStatement struct {
|
|||
|
||||
// DefineEventStatement represents an SQL DEFINE EVENT statement.
|
||||
type DefineEventStatement struct {
|
||||
KV string `cork:"-" codec:"-"`
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
Name *Ident `cork:"name" codec:"name"`
|
||||
What Tables `cork:"-" codec:"-"`
|
||||
When Expr `cork:"when" codec:"when"`
|
||||
Then Expr `cork:"then" codec:"then"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Name *Ident
|
||||
What Tables
|
||||
When Expr
|
||||
Then Expr
|
||||
}
|
||||
|
||||
// RemoveEventStatement represents an SQL REMOVE EVENT statement.
|
||||
type RemoveEventStatement struct {
|
||||
KV string `cork:"-" codec:"-"`
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
Name *Ident `cork:"-" codec:"-"`
|
||||
What Tables `cork:"-" codec:"-"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Name *Ident
|
||||
What Tables
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
|
@ -427,26 +428,26 @@ type RemoveEventStatement struct {
|
|||
|
||||
// DefineFieldStatement represents an SQL DEFINE FIELD statement.
|
||||
type DefineFieldStatement struct {
|
||||
KV string `cork:"-" codec:"-"`
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
Name *Ident `cork:"name" codec:"name"`
|
||||
What Tables `cork:"-" codec:"-"`
|
||||
Perms Expr `cork:"perms" codec:"perms"`
|
||||
Type string `cork:"type" codec:"type"`
|
||||
Kind string `cork:"kind" codec:"kind"`
|
||||
Value Expr `cork:"value" codec:"value"`
|
||||
Assert Expr `cork:"assert" codec:"assert"`
|
||||
Priority float64 `cork:"priority" codec:"priority"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Name *Ident
|
||||
What Tables
|
||||
Perms Expr
|
||||
Type string
|
||||
Kind string
|
||||
Value Expr
|
||||
Assert Expr
|
||||
Priority float64
|
||||
}
|
||||
|
||||
// RemoveFieldStatement represents an SQL REMOVE FIELD statement.
|
||||
type RemoveFieldStatement struct {
|
||||
KV string `cork:"-" codec:"-"`
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
Name *Ident `cork:"-" codec:"-"`
|
||||
What Tables `cork:"-" codec:"-"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Name *Ident
|
||||
What Tables
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
|
@ -455,22 +456,22 @@ type RemoveFieldStatement struct {
|
|||
|
||||
// DefineIndexStatement represents an SQL DEFINE INDEX statement.
|
||||
type DefineIndexStatement struct {
|
||||
KV string `cork:"-" codec:"-"`
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
Name *Ident `cork:"name" codec:"name"`
|
||||
What Tables `cork:"-" codec:"-"`
|
||||
Cols Idents `cork:"cols" codec:"cols"`
|
||||
Uniq bool `cork:"uniq" codec:"uniq"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Name *Ident
|
||||
What Tables
|
||||
Cols Idents
|
||||
Uniq bool
|
||||
}
|
||||
|
||||
// RemoveIndexStatement represents an SQL REMOVE INDEX statement.
|
||||
type RemoveIndexStatement struct {
|
||||
KV string `cork:"-" codec:"-"`
|
||||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
Name *Ident `cork:"-" codec:"-"`
|
||||
What Tables `cork:"-" codec:"-"`
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
Name *Ident
|
||||
What Tables
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
|
@ -626,22 +627,6 @@ type ContentExpression struct {
|
|||
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
|
||||
// --------------------------------------------------
|
||||
|
@ -651,43 +636,11 @@ type Params []*Param
|
|||
|
||||
// Param comment
|
||||
type Param struct {
|
||||
ID string
|
||||
VA string
|
||||
}
|
||||
|
||||
func NewParam(ID string) *Param {
|
||||
return &Param{ID}
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
// 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}
|
||||
func NewParam(VA string) *Param {
|
||||
return &Param{VA}
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
|
@ -699,11 +652,43 @@ type Idents []*Ident
|
|||
|
||||
// Ident comment
|
||||
type Ident struct {
|
||||
ID string
|
||||
VA string
|
||||
}
|
||||
|
||||
func NewIdent(ID string) *Ident {
|
||||
return &Ident{ID}
|
||||
func NewIdent(VA string) *Ident {
|
||||
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
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
// 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
|
||||
// --------------------------------------------------
|
||||
|
@ -831,7 +835,7 @@ type Polygons []*Polygon
|
|||
|
||||
// Polygon comment
|
||||
type Polygon struct {
|
||||
PS Points
|
||||
PS []*Point
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
if i, ok := g.Expr.(*Ident); ok {
|
||||
if e.Field == i.ID {
|
||||
if e.Field == i.VA {
|
||||
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) {
|
||||
case *Param:
|
||||
one.Field = v.ID
|
||||
case *Value:
|
||||
one.Field = v.ID
|
||||
one.Field = v.VA
|
||||
case *Ident:
|
||||
one.Field = v.ID
|
||||
one.Field = v.VA
|
||||
case *Value:
|
||||
one.Field = v.VA
|
||||
default:
|
||||
one.Field = one.String()
|
||||
}
|
||||
|
|
|
@ -440,7 +440,7 @@ func Test_Parse_Queries_Let(t *testing.T) {
|
|||
res: &Query{Statements: []Statement{&LetStatement{
|
||||
RW: false, KV: "*", NS: "*", DB: "*",
|
||||
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"},
|
||||
What: &SubExpression{Expr: &CreateStatement{
|
||||
KV: "*", NS: "*", DB: "*",
|
||||
What: Exprs{&Ident{ID: "person"}},
|
||||
What: Exprs{&Ident{"person"}},
|
||||
Echo: AFTER,
|
||||
}},
|
||||
}}},
|
||||
|
@ -552,7 +552,7 @@ func Test_Parse_Queries_Return(t *testing.T) {
|
|||
sql: `RETURN $test`,
|
||||
res: &Query{Statements: []Statement{&ReturnStatement{
|
||||
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: "*",
|
||||
What: Exprs{&SubExpression{Expr: &CreateStatement{
|
||||
KV: "*", NS: "*", DB: "*",
|
||||
What: Exprs{&Ident{ID: "person"}},
|
||||
What: Exprs{&Ident{"person"}},
|
||||
Echo: AFTER,
|
||||
}}},
|
||||
}}},
|
||||
|
@ -850,7 +850,7 @@ func Test_Parse_Queries_Select(t *testing.T) {
|
|||
},
|
||||
What: Exprs{&SubExpression{Expr: &CreateStatement{
|
||||
KV: "*", NS: "*", DB: "*",
|
||||
What: Exprs{&Ident{ID: "person"}},
|
||||
What: Exprs{&Ident{"person"}},
|
||||
Echo: AFTER,
|
||||
}}},
|
||||
}}},
|
||||
|
@ -1039,7 +1039,7 @@ func Test_Parse_Queries_Select(t *testing.T) {
|
|||
},
|
||||
Op: AND,
|
||||
RHS: &BinaryExpression{
|
||||
LHS: &Ident{ID: "id"},
|
||||
LHS: &Ident{"id"},
|
||||
Op: LTE,
|
||||
RHS: float64(29.9),
|
||||
},
|
||||
|
@ -1151,27 +1151,27 @@ func Test_Parse_Queries_Select(t *testing.T) {
|
|||
LHS: &BinaryExpression{
|
||||
LHS: &BinaryExpression{
|
||||
LHS: &BinaryExpression{
|
||||
LHS: &Ident{ID: "bday"},
|
||||
LHS: &Ident{"bday"},
|
||||
Op: GTE,
|
||||
RHS: bday1,
|
||||
},
|
||||
Op: AND,
|
||||
RHS: &BinaryExpression{
|
||||
LHS: &Ident{ID: "bday"},
|
||||
LHS: &Ident{"bday"},
|
||||
Op: GTE,
|
||||
RHS: bday2,
|
||||
},
|
||||
},
|
||||
Op: AND,
|
||||
RHS: &BinaryExpression{
|
||||
LHS: &Ident{ID: "bday"},
|
||||
LHS: &Ident{"bday"},
|
||||
Op: GTE,
|
||||
RHS: bday3,
|
||||
},
|
||||
},
|
||||
Op: AND,
|
||||
RHS: &BinaryExpression{
|
||||
LHS: &Ident{ID: "bday"},
|
||||
LHS: &Ident{"bday"},
|
||||
Op: LTE,
|
||||
RHS: bday4,
|
||||
},
|
||||
|
@ -2347,7 +2347,7 @@ func Test_Parse_Queries_Define(t *testing.T) {
|
|||
Signup: &SubExpression{
|
||||
Expr: &CreateStatement{
|
||||
KV: "*", NS: "*", DB: "*",
|
||||
What: Exprs{&Ident{ID: "person"}},
|
||||
What: Exprs{&Ident{"person"}},
|
||||
Echo: AFTER,
|
||||
},
|
||||
},
|
||||
|
@ -2532,7 +2532,7 @@ func Test_Parse_Queries_Define(t *testing.T) {
|
|||
Lock: true,
|
||||
Expr: Fields{
|
||||
&Field{
|
||||
Expr: &Ident{ID: "nationality"},
|
||||
Expr: &Ident{"nationality"},
|
||||
Field: "nationality",
|
||||
},
|
||||
&Field{
|
||||
|
@ -2549,13 +2549,13 @@ func Test_Parse_Queries_Define(t *testing.T) {
|
|||
&Table{TB: "users"},
|
||||
},
|
||||
Cond: &BinaryExpression{
|
||||
LHS: &Ident{ID: "public"},
|
||||
LHS: &Ident{"public"},
|
||||
Op: EQ,
|
||||
RHS: true,
|
||||
},
|
||||
Group: Groups{
|
||||
&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
|
||||
// ---------------------------------------------
|
||||
|
@ -586,39 +565,7 @@ func (this Params) String() string {
|
|||
}
|
||||
|
||||
func (this Param) String() string {
|
||||
return print("$%v", this.ID)
|
||||
}
|
||||
|
||||
// ---------------------------------------------
|
||||
// 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)
|
||||
return print("$%v", this.VA)
|
||||
}
|
||||
|
||||
// ---------------------------------------------
|
||||
|
@ -634,7 +581,39 @@ func (this Idents) 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)
|
||||
}
|
||||
|
||||
// ---------------------------------------------
|
||||
// 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
|
||||
// ---------------------------------------------
|
||||
|
|
|
@ -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 {
|
||||
for k, v := range tokens {
|
||||
if len(v) == len(s) {
|
||||
|
@ -444,6 +437,26 @@ func newToken(s string) Token {
|
|||
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) isKeyword() bool { return tok > keywordsBeg && tok < keywordsEnd }
|
||||
|
|
52
sql/util.go
52
sql/util.go
|
@ -20,7 +20,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
json "github.com/hjson/hjson-go"
|
||||
"github.com/hjson/hjson-go"
|
||||
)
|
||||
|
||||
func in(token Token, tokens []Token) bool {
|
||||
|
@ -73,44 +73,44 @@ func (p *parser) declare(tok Token, lit string) (interface{}, error) {
|
|||
case FALSE:
|
||||
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:
|
||||
return &All{}, nil
|
||||
return new(All), nil
|
||||
|
||||
case QMARK:
|
||||
return &Any{}, nil
|
||||
return new(Any), nil
|
||||
|
||||
case STRING:
|
||||
return &Value{lit}, nil
|
||||
case NULL:
|
||||
return new(Null), nil
|
||||
|
||||
case REGION:
|
||||
return &Value{lit}, nil
|
||||
case VOID:
|
||||
return new(Void), nil
|
||||
|
||||
case MISSING:
|
||||
return new(Void), nil
|
||||
|
||||
case EMPTY:
|
||||
return new(Empty), nil
|
||||
|
||||
case EXPR:
|
||||
return &Ident{lit}, nil
|
||||
return NewIdent(lit), nil
|
||||
|
||||
case IDENT:
|
||||
return &Ident{lit}, nil
|
||||
return NewIdent(lit), nil
|
||||
|
||||
case TABLE:
|
||||
return &Table{lit}, nil
|
||||
return NewTable(lit), nil
|
||||
|
||||
case PARAM:
|
||||
return &Param{lit}, nil
|
||||
return NewParam(lit), nil
|
||||
|
||||
case REGEX:
|
||||
return &Regex{lit}, nil
|
||||
return NewRegex(lit), nil
|
||||
|
||||
case STRING:
|
||||
return NewValue(lit), nil
|
||||
|
||||
case REGION:
|
||||
return NewValue(lit), nil
|
||||
|
||||
case DATE:
|
||||
return time.Parse(RFCDate, lit)
|
||||
|
@ -150,7 +150,7 @@ func (p *parser) declare(tok Token, lit string) (interface{}, error) {
|
|||
|
||||
case ARRAY:
|
||||
var j []interface{}
|
||||
json.Unmarshal([]byte(lit), &j)
|
||||
hjson.Unmarshal([]byte(lit), &j)
|
||||
if j == nil {
|
||||
return j, fmt.Errorf("Invalid JSON: %s", lit)
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ func (p *parser) declare(tok Token, lit string) (interface{}, error) {
|
|||
|
||||
case JSON:
|
||||
var j map[string]interface{}
|
||||
json.Unmarshal([]byte(lit), &j)
|
||||
hjson.Unmarshal([]byte(lit), &j)
|
||||
if j == nil {
|
||||
return j, fmt.Errorf("Invalid JSON: %s", lit)
|
||||
}
|
||||
|
|
|
@ -24,10 +24,10 @@ import (
|
|||
func get(ctx context.Context, args ...interface{}) (interface{}, error) {
|
||||
doc := data.Consume(args[0])
|
||||
switch fld := args[1].(type) {
|
||||
case *sql.Value:
|
||||
return doc.Get(fld.ID).Data(), nil
|
||||
case string:
|
||||
return doc.Get(fld).Data(), nil
|
||||
case *sql.Value:
|
||||
return doc.Get(fld.VA).Data(), nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ func Build(cols sql.Idents, item *data.Doc) (out [][]interface{}) {
|
|||
|
||||
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 _, a := range arr {
|
||||
idx := []interface{}{}
|
||||
|
@ -69,7 +69,7 @@ func Build(cols sql.Idents, item *data.Doc) (out [][]interface{}) {
|
|||
} else {
|
||||
for _, s := range sub {
|
||||
idx := []interface{}{}
|
||||
idx = append(idx, item.Get(col.ID).Data())
|
||||
idx = append(idx, item.Get(col.VA).Data())
|
||||
idx = append(idx, s...)
|
||||
out = append(out, idx)
|
||||
}
|
||||
|
|
|
@ -335,7 +335,7 @@ func checkBearer(c *fibre.Context, info string, callback func() error) (err erro
|
|||
|
||||
// Store the authenticated scope.
|
||||
|
||||
auth.Scope = scp.Name.ID
|
||||
auth.Scope = scp.Name.VA
|
||||
|
||||
// Store the authenticated thing.
|
||||
|
||||
|
|
Loading…
Reference in a new issue