Complete functionality to define scope tokens

This commit is contained in:
Tobie Morgan Hitchcock 2018-09-13 16:35:06 +01:00
parent 41c2fd0b3e
commit 918c696eb1
11 changed files with 1595 additions and 1384 deletions

View file

@ -11,23 +11,23 @@ import (
const ( const (
// ----- content types ---- // ----- content types ----
codecSelferCcUTF84219 = 1 codecSelferCcUTF87188 = 1
codecSelferCcRAW4219 = 0 codecSelferCcRAW7188 = 0
// ----- value types used ---- // ----- value types used ----
codecSelferValueTypeArray4219 = 10 codecSelferValueTypeArray7188 = 10
codecSelferValueTypeMap4219 = 9 codecSelferValueTypeMap7188 = 9
codecSelferValueTypeString4219 = 6 codecSelferValueTypeString7188 = 6
codecSelferValueTypeInt4219 = 2 codecSelferValueTypeInt7188 = 2
codecSelferValueTypeUint4219 = 3 codecSelferValueTypeUint7188 = 3
codecSelferValueTypeFloat4219 = 4 codecSelferValueTypeFloat7188 = 4
codecSelferBitsize4219 = uint8(32 << (^uint(0) >> 63)) codecSelferBitsize7188 = uint8(32 << (^uint(0) >> 63))
) )
var ( var (
errCodecSelferOnlyMapOrArrayEncodeToStruct4219 = errors.New(`only encoded map or array can be decoded into a struct`) errCodecSelferOnlyMapOrArrayEncodeToStruct7188 = errors.New(`only encoded map or array can be decoded into a struct`)
) )
type codecSelfer4219 struct{} type codecSelfer7188 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 codecSelfer4219 var h codecSelfer7188
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(codecSelferCcUTF84219, string(x.Time)) r.EncodeString(codecSelferCcUTF87188, string(x.Time))
} }
} else { } else {
r.EncodeString(codecSelferCcUTF84219, "") r.EncodeString(codecSelferCcUTF87188, "")
} }
} else { } else {
if yyq2[0] { if yyq2[0] {
r.WriteMapElemKey() r.WriteMapElemKey()
r.EncodeString(codecSelferCcUTF84219, `time`) r.EncodeString(codecSelferCcUTF87188, `time`)
r.WriteMapElemValue() r.WriteMapElemValue()
if false { if false {
} else { } else {
r.EncodeString(codecSelferCcUTF84219, string(x.Time)) r.EncodeString(codecSelferCcUTF87188, 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(codecSelferCcUTF84219, string(x.Status)) r.EncodeString(codecSelferCcUTF87188, string(x.Status))
} }
} else { } else {
r.EncodeString(codecSelferCcUTF84219, "") r.EncodeString(codecSelferCcUTF87188, "")
} }
} else { } else {
if yyq2[1] { if yyq2[1] {
r.WriteMapElemKey() r.WriteMapElemKey()
r.EncodeString(codecSelferCcUTF84219, `status`) r.EncodeString(codecSelferCcUTF87188, `status`)
r.WriteMapElemValue() r.WriteMapElemValue()
if false { if false {
} else { } else {
r.EncodeString(codecSelferCcUTF84219, string(x.Status)) r.EncodeString(codecSelferCcUTF87188, 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(codecSelferCcUTF84219, string(x.Detail)) r.EncodeString(codecSelferCcUTF87188, string(x.Detail))
} }
} else { } else {
r.EncodeString(codecSelferCcUTF84219, "") r.EncodeString(codecSelferCcUTF87188, "")
} }
} else { } else {
if yyq2[2] { if yyq2[2] {
r.WriteMapElemKey() r.WriteMapElemKey()
r.EncodeString(codecSelferCcUTF84219, `detail`) r.EncodeString(codecSelferCcUTF87188, `detail`)
r.WriteMapElemValue() r.WriteMapElemValue()
if false { if false {
} else { } else {
r.EncodeString(codecSelferCcUTF84219, string(x.Detail)) r.EncodeString(codecSelferCcUTF87188, 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(codecSelferCcUTF84219, `result`) r.EncodeString(codecSelferCcUTF87188, `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 codecSelfer4219 var h codecSelfer7188
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 == codecSelferValueTypeMap4219 { if yyct2 == codecSelferValueTypeMap7188 {
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 == codecSelferValueTypeArray4219 { } else if yyct2 == codecSelferValueTypeArray7188 {
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(errCodecSelferOnlyMapOrArrayEncodeToStruct4219) panic(errCodecSelferOnlyMapOrArrayEncodeToStruct7188)
} }
} }
} }
func (x *Response) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { func (x *Response) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
var h codecSelfer4219 var h codecSelfer7188
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 codecSelfer4219 var h codecSelfer7188
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 codecSelfer4219 var h codecSelfer7188
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(codecSelferCcUTF84219, string(x.Query)) r.EncodeString(codecSelferCcUTF87188, string(x.Query))
} }
} else { } else {
r.EncodeString(codecSelferCcUTF84219, "") r.EncodeString(codecSelferCcUTF87188, "")
} }
} else { } else {
if yyq2[0] { if yyq2[0] {
r.WriteMapElemKey() r.WriteMapElemKey()
r.EncodeString(codecSelferCcUTF84219, `query`) r.EncodeString(codecSelferCcUTF87188, `query`)
r.WriteMapElemValue() r.WriteMapElemValue()
if false { if false {
} else { } else {
r.EncodeString(codecSelferCcUTF84219, string(x.Query)) r.EncodeString(codecSelferCcUTF87188, 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(codecSelferCcUTF84219, string(x.Action)) r.EncodeString(codecSelferCcUTF87188, string(x.Action))
} }
} else { } else {
r.EncodeString(codecSelferCcUTF84219, "") r.EncodeString(codecSelferCcUTF87188, "")
} }
} else { } else {
if yyq2[1] { if yyq2[1] {
r.WriteMapElemKey() r.WriteMapElemKey()
r.EncodeString(codecSelferCcUTF84219, `action`) r.EncodeString(codecSelferCcUTF87188, `action`)
r.WriteMapElemValue() r.WriteMapElemValue()
if false { if false {
} else { } else {
r.EncodeString(codecSelferCcUTF84219, string(x.Action)) r.EncodeString(codecSelferCcUTF87188, 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(codecSelferCcUTF84219, `result`) r.EncodeString(codecSelferCcUTF87188, `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 codecSelfer4219 var h codecSelfer7188
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 == codecSelferValueTypeMap4219 { if yyct2 == codecSelferValueTypeMap7188 {
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 == codecSelferValueTypeArray4219 { } else if yyct2 == codecSelferValueTypeArray7188 {
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(errCodecSelferOnlyMapOrArrayEncodeToStruct4219) panic(errCodecSelferOnlyMapOrArrayEncodeToStruct7188)
} }
} }
} }
func (x *Dispatch) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { func (x *Dispatch) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
var h codecSelfer4219 var h codecSelfer7188
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 codecSelfer4219 var h codecSelfer7188
z, r := codec1978.GenHelperDecoder(d) z, r := codec1978.GenHelperDecoder(d)
_, _, _ = h, z, r _, _, _ = h, z, r
var yyj8 int var yyj8 int

View file

@ -94,6 +94,14 @@ func (e *executor) executeDefineToken(ctx context.Context, ast *sql.DefineTokenS
tkey := &keys.DT{KV: ast.KV, NS: ast.NS, DB: ast.DB, TK: ast.Name.VA} 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())
case sql.SCOPE:
e.dbo.AddDB(ctx, ast.NS, ast.DB)
// Save the token definition
tkey := &keys.ST{KV: ast.KV, NS: ast.NS, DB: ast.DB, SC: ast.What.VA, TK: ast.Name.VA}
_, err = e.dbo.Put(ctx, 0, tkey.Encode(), ast.Encode())
} }
return return

View file

@ -89,6 +89,12 @@ func (e *executor) executeRemoveToken(ctx context.Context, ast *sql.RemoveTokenS
tkey := &keys.DT{KV: ast.KV, NS: ast.NS, DB: ast.DB, TK: ast.Name.VA} 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)
case sql.SCOPE:
// Remove the token definition
tkey := &keys.ST{KV: ast.KV, NS: ast.NS, DB: ast.DB, SC: ast.What.VA, TK: ast.Name.VA}
_, err = e.dbo.ClrP(ctx, tkey.Encode(), 0)
} }
return return

File diff suppressed because it is too large Load diff

View file

@ -328,6 +328,7 @@ type DefineTokenStatement struct {
DB string DB string
Kind Token Kind Token
Name *Ident Name *Ident
What *Ident
Type string Type string
Code []byte Code []byte
} }
@ -339,6 +340,7 @@ type RemoveTokenStatement struct {
DB string DB string
Kind Token Kind Token
Name *Ident Name *Ident
What *Ident
} }
// -------------------------------------------------- // --------------------------------------------------

View file

@ -1406,6 +1406,7 @@ func (this *DefineTokenStatement) ExtendCORK() byte {
func (this *DefineTokenStatement) MarshalCORK(w *cork.Writer) (err error) { func (this *DefineTokenStatement) MarshalCORK(w *cork.Writer) (err error) {
w.EncodeAny(this.Kind) w.EncodeAny(this.Kind)
w.EncodeAny(this.Name) w.EncodeAny(this.Name)
w.EncodeAny(this.What)
w.EncodeAny(this.Type) w.EncodeAny(this.Type)
w.EncodeBytes(this.Code) w.EncodeBytes(this.Code)
return return
@ -1414,6 +1415,7 @@ func (this *DefineTokenStatement) MarshalCORK(w *cork.Writer) (err error) {
func (this *DefineTokenStatement) UnmarshalCORK(r *cork.Reader) (err error) { func (this *DefineTokenStatement) UnmarshalCORK(r *cork.Reader) (err error) {
r.DecodeAny(&this.Kind) r.DecodeAny(&this.Kind)
r.DecodeAny(&this.Name) r.DecodeAny(&this.Name)
r.DecodeAny(&this.What)
r.DecodeAny(&this.Type) r.DecodeAny(&this.Type)
r.DecodeBytes(&this.Code) r.DecodeBytes(&this.Code)
return return

View file

@ -2266,6 +2266,7 @@ func Test_Parse_Queries_Define(t *testing.T) {
KV: "*", NS: "*", DB: "*", KV: "*", NS: "*", DB: "*",
Kind: NAMESPACE, Kind: NAMESPACE,
Name: &Ident{"test"}, Name: &Ident{"test"},
What: &Ident{""},
Type: "HS512", Type: "HS512",
Code: []byte("secret"), Code: []byte("secret"),
}}}, }}},
@ -2277,23 +2278,25 @@ func Test_Parse_Queries_Define(t *testing.T) {
KV: "*", NS: "*", DB: "*", KV: "*", NS: "*", DB: "*",
Kind: DATABASE, Kind: DATABASE,
Name: &Ident{"test"}, Name: &Ident{"test"},
What: &Ident{""},
Type: "HS512", Type: "HS512",
Code: []byte("secret"), Code: []byte("secret"),
}}}, }}},
}, },
{ {
sql: `DEFINE TOKEN test ON SCOPE TYPE HS512 VALUE "secret"`, sql: `DEFINE TOKEN test ON SCOPE test TYPE HS512 VALUE "secret"`,
str: `DEFINE TOKEN test ON SCOPE TYPE HS512 VALUE ********`, str: `DEFINE TOKEN test ON SCOPE test TYPE HS512 VALUE ********`,
res: &Query{Statements: []Statement{&DefineTokenStatement{ res: &Query{Statements: []Statement{&DefineTokenStatement{
KV: "*", NS: "*", DB: "*", KV: "*", NS: "*", DB: "*",
Kind: SCOPE, Kind: SCOPE,
Name: &Ident{"test"}, Name: &Ident{"test"},
What: &Ident{"test"},
Type: "HS512", Type: "HS512",
Code: []byte("secret"), Code: []byte("secret"),
}}}, }}},
}, },
{ {
sql: `DEFINE TOKEN test ON SCOPE TYPE HS512 VALUE "secret" something`, sql: `DEFINE TOKEN test ON SCOPE test TYPE HS512 VALUE "secret" something`,
err: "Found `something` but expected `;`", err: "Found `something` but expected `;`",
}, },
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -3104,6 +3107,7 @@ func Test_Parse_Queries_Remove(t *testing.T) {
KV: "*", NS: "*", DB: "*", KV: "*", NS: "*", DB: "*",
Kind: NAMESPACE, Kind: NAMESPACE,
Name: &Ident{"test"}, Name: &Ident{"test"},
What: &Ident{""},
}}}, }}},
}, },
{ {
@ -3112,14 +3116,20 @@ func Test_Parse_Queries_Remove(t *testing.T) {
KV: "*", NS: "*", DB: "*", KV: "*", NS: "*", DB: "*",
Kind: DATABASE, Kind: DATABASE,
Name: &Ident{"test"}, Name: &Ident{"test"},
What: &Ident{""},
}}}, }}},
}, },
{ {
sql: `REMOVE TOKEN test ON SCOPE`, sql: `REMOVE TOKEN test ON SCOPE`,
err: "Found `` but expected `name`",
},
{
sql: `REMOVE TOKEN test ON SCOPE test`,
res: &Query{Statements: []Statement{&RemoveTokenStatement{ res: &Query{Statements: []Statement{&RemoveTokenStatement{
KV: "*", NS: "*", DB: "*", KV: "*", NS: "*", DB: "*",
Kind: SCOPE, Kind: SCOPE,
Name: &Ident{"test"}, Name: &Ident{"test"},
What: &Ident{"test"},
}}}, }}},
}, },
{ {

View file

@ -91,6 +91,10 @@ func maybe(b bool, v ...interface{}) string {
return "" return ""
} }
func binar(b []byte) string {
return fmt.Sprintf(`"%s"`, b)
}
func quote(s string) string { func quote(s string) string {
t := newToken(s) t := newToken(s)
switch t { switch t {
@ -331,7 +335,7 @@ func (this RemoveLoginStatement) String() string {
func (this DefineTokenStatement) String() string { func (this DefineTokenStatement) String() string {
return print("DEFINE TOKEN %v ON %v TYPE %v VALUE ********", return print("DEFINE TOKEN %v ON %v TYPE %v VALUE ********",
this.Name, this.Name,
this.Kind, maybe(this.Kind == SCOPE, print("%v %v", this.Kind, this.What), print("%v", this.Kind)),
this.Type, this.Type,
) )
} }
@ -339,7 +343,7 @@ func (this DefineTokenStatement) String() string {
func (this RemoveTokenStatement) String() string { func (this RemoveTokenStatement) String() string {
return print("REMOVE TOKEN %v ON %v", return print("REMOVE TOKEN %v ON %v",
this.Name, this.Name,
this.Kind, maybe(this.Kind == SCOPE, print("%v %v", this.Kind, this.What), print("%v", this.Kind)),
) )
} }

View file

@ -18,6 +18,8 @@ func (p *parser) parseDefineTokenStatement() (stmt *DefineTokenStatement, err er
stmt = &DefineTokenStatement{} stmt = &DefineTokenStatement{}
stmt.What = &Ident{}
if stmt.Name, err = p.parseIdent(); err != nil { if stmt.Name, err = p.parseIdent(); err != nil {
return nil, err return nil, err
} }
@ -46,6 +48,9 @@ func (p *parser) parseDefineTokenStatement() (stmt *DefineTokenStatement, err er
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil { if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil {
return nil, err return nil, err
} }
if stmt.What, err = p.parseIdent(); err != nil {
return nil, err
}
} }
for { for {
@ -85,6 +90,8 @@ func (p *parser) parseRemoveTokenStatement() (stmt *RemoveTokenStatement, err er
stmt = &RemoveTokenStatement{} stmt = &RemoveTokenStatement{}
stmt.What = &Ident{}
if stmt.Name, err = p.parseIdent(); err != nil { if stmt.Name, err = p.parseIdent(); err != nil {
return nil, err return nil, err
} }
@ -113,6 +120,9 @@ func (p *parser) parseRemoveTokenStatement() (stmt *RemoveTokenStatement, err er
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil { if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil {
return nil, err return nil, err
} }
if stmt.What, err = p.parseIdent(); err != nil {
return nil, err
}
} }
return return

View file

@ -126,7 +126,7 @@ func TestMain(t *testing.T) {
new: &SC{}, new: &SC{},
}, },
{ {
str: "/surreal/*/abcum/*/database/!/s/admin/!/k/default", str: "/surreal/*/abcum/*/database/!/st/admin/!/k/default",
obj: &ST{KV: "surreal", NS: "abcum", DB: "database", SC: "admin", TK: "default"}, obj: &ST{KV: "surreal", NS: "abcum", DB: "database", SC: "admin", TK: "default"},
new: &ST{}, new: &ST{},
}, },

View file

@ -42,7 +42,7 @@ func (k *ST) Copy() *ST {
// Encode encodes the key into binary // Encode encodes the key into binary
func (k *ST) Encode() []byte { func (k *ST) Encode() []byte {
k.init() k.init()
return encode(k.KV, "*", k.NS, "*", k.DB, "!", "s", k.SC, "!", "k", k.TK) return encode(k.KV, "*", k.NS, "*", k.DB, "!", "st", k.SC, "!", "k", k.TK)
} }
// Decode decodes the key from binary // Decode decodes the key from binary
@ -55,5 +55,5 @@ func (k *ST) Decode(data []byte) {
// String returns a string representation of the key // String returns a string representation of the key
func (k *ST) String() string { func (k *ST) String() string {
k.init() k.init()
return output(k.KV, "*", k.NS, "*", k.DB, "!", "s", k.SC, "!", "k", k.TK) return output(k.KV, "*", k.NS, "*", k.DB, "!", "st", k.SC, "!", "k", k.TK)
} }