Make sure LV database key specifies a table
This commit is contained in:
parent
6a1ec1b2bb
commit
21cb197d5a
2 changed files with 10 additions and 8 deletions
|
@ -105,11 +105,6 @@ func TestMain(t *testing.T) {
|
|||
obj: &DB{KV: "surreal", NS: "abcum", DB: "database"},
|
||||
new: &DB{},
|
||||
},
|
||||
{
|
||||
str: "/surreal/abcum/*/database/!/l/df8c74fa-428a-42b7-b279-b5fbe33d72a7",
|
||||
obj: &LV{KV: "surreal", NS: "abcum", DB: "database", LV: "df8c74fa-428a-42b7-b279-b5fbe33d72a7"},
|
||||
new: &LV{},
|
||||
},
|
||||
{
|
||||
str: "/surreal/abcum/*/database/!/s/admin",
|
||||
obj: &SC{KV: "surreal", NS: "abcum", DB: "database", SC: "admin"},
|
||||
|
@ -145,6 +140,11 @@ func TestMain(t *testing.T) {
|
|||
obj: &IX{KV: "surreal", NS: "abcum", DB: "database", TB: "person", IX: "teenagers"},
|
||||
new: &IX{},
|
||||
},
|
||||
{
|
||||
str: "/surreal/abcum/*/database/*/person/!/l/realtime",
|
||||
obj: &LV{KV: "surreal", NS: "abcum", DB: "database", TB: "person", LV: "realtime"},
|
||||
new: &LV{},
|
||||
},
|
||||
{
|
||||
str: "/surreal/abcum/*/database/*/person/*",
|
||||
obj: &Table{KV: "surreal", NS: "abcum", DB: "database", TB: "person"},
|
||||
|
|
|
@ -19,6 +19,7 @@ type LV struct {
|
|||
KV string
|
||||
NS string
|
||||
DB string
|
||||
TB string
|
||||
LV string
|
||||
}
|
||||
|
||||
|
@ -33,6 +34,7 @@ func (k *LV) Copy() *LV {
|
|||
KV: k.KV,
|
||||
NS: k.NS,
|
||||
DB: k.DB,
|
||||
TB: k.TB,
|
||||
LV: k.LV,
|
||||
}
|
||||
}
|
||||
|
@ -40,17 +42,17 @@ func (k *LV) Copy() *LV {
|
|||
// Encode encodes the key into binary
|
||||
func (k *LV) Encode() []byte {
|
||||
k.init()
|
||||
return encode(k.KV, k.NS, "*", k.DB, "!", "l", k.LV)
|
||||
return encode(k.KV, k.NS, "*", k.DB, "*", k.TB, "!", "l", k.LV)
|
||||
}
|
||||
|
||||
// Decode decodes the key from binary
|
||||
func (k *LV) Decode(data []byte) {
|
||||
k.init()
|
||||
decode(data, &k.KV, &k.NS, &skip, &k.DB, &skip, &skip, &k.LV)
|
||||
decode(data, &k.KV, &k.NS, &skip, &k.DB, &skip, &k.TB, &skip, &skip, &k.LV)
|
||||
}
|
||||
|
||||
// String returns a string representation of the key
|
||||
func (k *LV) String() string {
|
||||
k.init()
|
||||
return output(k.KV, k.NS, "*", k.DB, "!", "l", k.LV)
|
||||
return output(k.KV, k.NS, "*", k.DB, "*", k.TB, "!", "l", k.LV)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue