Complete functionality to define scope tokens
This commit is contained in:
parent
41c2fd0b3e
commit
918c696eb1
11 changed files with 1595 additions and 1384 deletions
94
db/db.gen.go
94
db/db.gen.go
|
@ -11,23 +11,23 @@ import (
|
|||
|
||||
const (
|
||||
// ----- content types ----
|
||||
codecSelferCcUTF84219 = 1
|
||||
codecSelferCcRAW4219 = 0
|
||||
codecSelferCcUTF87188 = 1
|
||||
codecSelferCcRAW7188 = 0
|
||||
// ----- value types used ----
|
||||
codecSelferValueTypeArray4219 = 10
|
||||
codecSelferValueTypeMap4219 = 9
|
||||
codecSelferValueTypeString4219 = 6
|
||||
codecSelferValueTypeInt4219 = 2
|
||||
codecSelferValueTypeUint4219 = 3
|
||||
codecSelferValueTypeFloat4219 = 4
|
||||
codecSelferBitsize4219 = uint8(32 << (^uint(0) >> 63))
|
||||
codecSelferValueTypeArray7188 = 10
|
||||
codecSelferValueTypeMap7188 = 9
|
||||
codecSelferValueTypeString7188 = 6
|
||||
codecSelferValueTypeInt7188 = 2
|
||||
codecSelferValueTypeUint7188 = 3
|
||||
codecSelferValueTypeFloat7188 = 4
|
||||
codecSelferBitsize7188 = uint8(32 << (^uint(0) >> 63))
|
||||
)
|
||||
|
||||
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() {
|
||||
if codec1978.GenVersion != 8 {
|
||||
|
@ -39,7 +39,7 @@ func init() {
|
|||
}
|
||||
|
||||
func (x *Response) CodecEncodeSelf(e *codec1978.Encoder) {
|
||||
var h codecSelfer4219
|
||||
var h codecSelfer7188
|
||||
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(codecSelferCcUTF84219, string(x.Time))
|
||||
r.EncodeString(codecSelferCcUTF87188, string(x.Time))
|
||||
}
|
||||
} else {
|
||||
r.EncodeString(codecSelferCcUTF84219, "")
|
||||
r.EncodeString(codecSelferCcUTF87188, "")
|
||||
}
|
||||
} else {
|
||||
if yyq2[0] {
|
||||
r.WriteMapElemKey()
|
||||
r.EncodeString(codecSelferCcUTF84219, `time`)
|
||||
r.EncodeString(codecSelferCcUTF87188, `time`)
|
||||
r.WriteMapElemValue()
|
||||
if false {
|
||||
} 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 false {
|
||||
} else {
|
||||
r.EncodeString(codecSelferCcUTF84219, string(x.Status))
|
||||
r.EncodeString(codecSelferCcUTF87188, string(x.Status))
|
||||
}
|
||||
} else {
|
||||
r.EncodeString(codecSelferCcUTF84219, "")
|
||||
r.EncodeString(codecSelferCcUTF87188, "")
|
||||
}
|
||||
} else {
|
||||
if yyq2[1] {
|
||||
r.WriteMapElemKey()
|
||||
r.EncodeString(codecSelferCcUTF84219, `status`)
|
||||
r.EncodeString(codecSelferCcUTF87188, `status`)
|
||||
r.WriteMapElemValue()
|
||||
if false {
|
||||
} 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 false {
|
||||
} else {
|
||||
r.EncodeString(codecSelferCcUTF84219, string(x.Detail))
|
||||
r.EncodeString(codecSelferCcUTF87188, string(x.Detail))
|
||||
}
|
||||
} else {
|
||||
r.EncodeString(codecSelferCcUTF84219, "")
|
||||
r.EncodeString(codecSelferCcUTF87188, "")
|
||||
}
|
||||
} else {
|
||||
if yyq2[2] {
|
||||
r.WriteMapElemKey()
|
||||
r.EncodeString(codecSelferCcUTF84219, `detail`)
|
||||
r.EncodeString(codecSelferCcUTF87188, `detail`)
|
||||
r.WriteMapElemValue()
|
||||
if false {
|
||||
} 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 {
|
||||
if yyq2[3] {
|
||||
r.WriteMapElemKey()
|
||||
r.EncodeString(codecSelferCcUTF84219, `result`)
|
||||
r.EncodeString(codecSelferCcUTF87188, `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 codecSelfer4219
|
||||
var h codecSelfer7188
|
||||
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 == codecSelferValueTypeMap4219 {
|
||||
if yyct2 == codecSelferValueTypeMap7188 {
|
||||
yyl2 := r.ReadMapStart()
|
||||
if yyl2 == 0 {
|
||||
r.ReadMapEnd()
|
||||
} else {
|
||||
x.codecDecodeSelfFromMap(yyl2, d)
|
||||
}
|
||||
} else if yyct2 == codecSelferValueTypeArray4219 {
|
||||
} else if yyct2 == codecSelferValueTypeArray7188 {
|
||||
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(errCodecSelferOnlyMapOrArrayEncodeToStruct4219)
|
||||
panic(errCodecSelferOnlyMapOrArrayEncodeToStruct7188)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Response) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
|
||||
var h codecSelfer4219
|
||||
var h codecSelfer7188
|
||||
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 codecSelfer4219
|
||||
var h codecSelfer7188
|
||||
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 codecSelfer4219
|
||||
var h codecSelfer7188
|
||||
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(codecSelferCcUTF84219, string(x.Query))
|
||||
r.EncodeString(codecSelferCcUTF87188, string(x.Query))
|
||||
}
|
||||
} else {
|
||||
r.EncodeString(codecSelferCcUTF84219, "")
|
||||
r.EncodeString(codecSelferCcUTF87188, "")
|
||||
}
|
||||
} else {
|
||||
if yyq2[0] {
|
||||
r.WriteMapElemKey()
|
||||
r.EncodeString(codecSelferCcUTF84219, `query`)
|
||||
r.EncodeString(codecSelferCcUTF87188, `query`)
|
||||
r.WriteMapElemValue()
|
||||
if false {
|
||||
} 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 false {
|
||||
} else {
|
||||
r.EncodeString(codecSelferCcUTF84219, string(x.Action))
|
||||
r.EncodeString(codecSelferCcUTF87188, string(x.Action))
|
||||
}
|
||||
} else {
|
||||
r.EncodeString(codecSelferCcUTF84219, "")
|
||||
r.EncodeString(codecSelferCcUTF87188, "")
|
||||
}
|
||||
} else {
|
||||
if yyq2[1] {
|
||||
r.WriteMapElemKey()
|
||||
r.EncodeString(codecSelferCcUTF84219, `action`)
|
||||
r.EncodeString(codecSelferCcUTF87188, `action`)
|
||||
r.WriteMapElemValue()
|
||||
if false {
|
||||
} 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 {
|
||||
if yyq2[2] {
|
||||
r.WriteMapElemKey()
|
||||
r.EncodeString(codecSelferCcUTF84219, `result`)
|
||||
r.EncodeString(codecSelferCcUTF87188, `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 codecSelfer4219
|
||||
var h codecSelfer7188
|
||||
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 == codecSelferValueTypeMap4219 {
|
||||
if yyct2 == codecSelferValueTypeMap7188 {
|
||||
yyl2 := r.ReadMapStart()
|
||||
if yyl2 == 0 {
|
||||
r.ReadMapEnd()
|
||||
} else {
|
||||
x.codecDecodeSelfFromMap(yyl2, d)
|
||||
}
|
||||
} else if yyct2 == codecSelferValueTypeArray4219 {
|
||||
} else if yyct2 == codecSelferValueTypeArray7188 {
|
||||
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(errCodecSelferOnlyMapOrArrayEncodeToStruct4219)
|
||||
panic(errCodecSelferOnlyMapOrArrayEncodeToStruct7188)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Dispatch) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
|
||||
var h codecSelfer4219
|
||||
var h codecSelfer7188
|
||||
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 codecSelfer4219
|
||||
var h codecSelfer7188
|
||||
z, r := codec1978.GenHelperDecoder(d)
|
||||
_, _, _ = h, z, r
|
||||
var yyj8 int
|
||||
|
|
|
@ -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}
|
||||
_, 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
|
||||
|
|
|
@ -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}
|
||||
_, 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
|
||||
|
|
2825
sql/ast.gen.go
2825
sql/ast.gen.go
File diff suppressed because it is too large
Load diff
|
@ -328,6 +328,7 @@ type DefineTokenStatement struct {
|
|||
DB string
|
||||
Kind Token
|
||||
Name *Ident
|
||||
What *Ident
|
||||
Type string
|
||||
Code []byte
|
||||
}
|
||||
|
@ -339,6 +340,7 @@ type RemoveTokenStatement struct {
|
|||
DB string
|
||||
Kind Token
|
||||
Name *Ident
|
||||
What *Ident
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
|
|
|
@ -1406,6 +1406,7 @@ func (this *DefineTokenStatement) ExtendCORK() byte {
|
|||
func (this *DefineTokenStatement) MarshalCORK(w *cork.Writer) (err error) {
|
||||
w.EncodeAny(this.Kind)
|
||||
w.EncodeAny(this.Name)
|
||||
w.EncodeAny(this.What)
|
||||
w.EncodeAny(this.Type)
|
||||
w.EncodeBytes(this.Code)
|
||||
return
|
||||
|
@ -1414,6 +1415,7 @@ func (this *DefineTokenStatement) MarshalCORK(w *cork.Writer) (err error) {
|
|||
func (this *DefineTokenStatement) UnmarshalCORK(r *cork.Reader) (err error) {
|
||||
r.DecodeAny(&this.Kind)
|
||||
r.DecodeAny(&this.Name)
|
||||
r.DecodeAny(&this.What)
|
||||
r.DecodeAny(&this.Type)
|
||||
r.DecodeBytes(&this.Code)
|
||||
return
|
||||
|
|
|
@ -2266,6 +2266,7 @@ func Test_Parse_Queries_Define(t *testing.T) {
|
|||
KV: "*", NS: "*", DB: "*",
|
||||
Kind: NAMESPACE,
|
||||
Name: &Ident{"test"},
|
||||
What: &Ident{""},
|
||||
Type: "HS512",
|
||||
Code: []byte("secret"),
|
||||
}}},
|
||||
|
@ -2277,23 +2278,25 @@ func Test_Parse_Queries_Define(t *testing.T) {
|
|||
KV: "*", NS: "*", DB: "*",
|
||||
Kind: DATABASE,
|
||||
Name: &Ident{"test"},
|
||||
What: &Ident{""},
|
||||
Type: "HS512",
|
||||
Code: []byte("secret"),
|
||||
}}},
|
||||
},
|
||||
{
|
||||
sql: `DEFINE TOKEN test ON SCOPE TYPE HS512 VALUE "secret"`,
|
||||
str: `DEFINE TOKEN test ON SCOPE TYPE HS512 VALUE ********`,
|
||||
sql: `DEFINE TOKEN test ON SCOPE test TYPE HS512 VALUE "secret"`,
|
||||
str: `DEFINE TOKEN test ON SCOPE test TYPE HS512 VALUE ********`,
|
||||
res: &Query{Statements: []Statement{&DefineTokenStatement{
|
||||
KV: "*", NS: "*", DB: "*",
|
||||
Kind: SCOPE,
|
||||
Name: &Ident{"test"},
|
||||
What: &Ident{"test"},
|
||||
Type: "HS512",
|
||||
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 `;`",
|
||||
},
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -3104,6 +3107,7 @@ func Test_Parse_Queries_Remove(t *testing.T) {
|
|||
KV: "*", NS: "*", DB: "*",
|
||||
Kind: NAMESPACE,
|
||||
Name: &Ident{"test"},
|
||||
What: &Ident{""},
|
||||
}}},
|
||||
},
|
||||
{
|
||||
|
@ -3112,14 +3116,20 @@ func Test_Parse_Queries_Remove(t *testing.T) {
|
|||
KV: "*", NS: "*", DB: "*",
|
||||
Kind: DATABASE,
|
||||
Name: &Ident{"test"},
|
||||
What: &Ident{""},
|
||||
}}},
|
||||
},
|
||||
{
|
||||
sql: `REMOVE TOKEN test ON SCOPE`,
|
||||
err: "Found `` but expected `name`",
|
||||
},
|
||||
{
|
||||
sql: `REMOVE TOKEN test ON SCOPE test`,
|
||||
res: &Query{Statements: []Statement{&RemoveTokenStatement{
|
||||
KV: "*", NS: "*", DB: "*",
|
||||
Kind: SCOPE,
|
||||
Name: &Ident{"test"},
|
||||
What: &Ident{"test"},
|
||||
}}},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -91,6 +91,10 @@ func maybe(b bool, v ...interface{}) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func binar(b []byte) string {
|
||||
return fmt.Sprintf(`"%s"`, b)
|
||||
}
|
||||
|
||||
func quote(s string) string {
|
||||
t := newToken(s)
|
||||
switch t {
|
||||
|
@ -331,7 +335,7 @@ func (this RemoveLoginStatement) String() string {
|
|||
func (this DefineTokenStatement) String() string {
|
||||
return print("DEFINE TOKEN %v ON %v TYPE %v VALUE ********",
|
||||
this.Name,
|
||||
this.Kind,
|
||||
maybe(this.Kind == SCOPE, print("%v %v", this.Kind, this.What), print("%v", this.Kind)),
|
||||
this.Type,
|
||||
)
|
||||
}
|
||||
|
@ -339,7 +343,7 @@ func (this DefineTokenStatement) String() string {
|
|||
func (this RemoveTokenStatement) String() string {
|
||||
return print("REMOVE TOKEN %v ON %v",
|
||||
this.Name,
|
||||
this.Kind,
|
||||
maybe(this.Kind == SCOPE, print("%v %v", this.Kind, this.What), print("%v", this.Kind)),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
10
sql/token.go
10
sql/token.go
|
@ -18,6 +18,8 @@ func (p *parser) parseDefineTokenStatement() (stmt *DefineTokenStatement, err er
|
|||
|
||||
stmt = &DefineTokenStatement{}
|
||||
|
||||
stmt.What = &Ident{}
|
||||
|
||||
if stmt.Name, err = p.parseIdent(); err != nil {
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
if stmt.What, err = p.parseIdent(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
for {
|
||||
|
@ -85,6 +90,8 @@ func (p *parser) parseRemoveTokenStatement() (stmt *RemoveTokenStatement, err er
|
|||
|
||||
stmt = &RemoveTokenStatement{}
|
||||
|
||||
stmt.What = &Ident{}
|
||||
|
||||
if stmt.Name, err = p.parseIdent(); err != nil {
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
if stmt.What, err = p.parseIdent(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
@ -126,7 +126,7 @@ func TestMain(t *testing.T) {
|
|||
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"},
|
||||
new: &ST{},
|
||||
},
|
||||
|
|
|
@ -42,7 +42,7 @@ func (k *ST) Copy() *ST {
|
|||
// Encode encodes the key into binary
|
||||
func (k *ST) Encode() []byte {
|
||||
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
|
||||
|
@ -55,5 +55,5 @@ func (k *ST) Decode(data []byte) {
|
|||
// String returns a string representation of the key
|
||||
func (k *ST) String() string {
|
||||
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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue