Db service fixes and improvements: dot access, truncate table etc (#157)

This commit is contained in:
Janos Dobronszki
2021-06-14 12:32:38 +01:00
committed by GitHub
parent 917d4f2d3f
commit e4be18434c
6 changed files with 324 additions and 70 deletions

View File

@@ -8,6 +8,13 @@ import (
"github.com/crufter/lexer"
)
func TestCorrectFieldName(t *testing.T) {
f := correctFieldName("a.b.c")
if f != "data ->> 'a' ->> 'b' ->> 'c'" {
t.Fatal(f)
}
}
func TestLexing(t *testing.T) {
tokens, err := lexer.Lex("a == 12", expressions)
if err != nil {
@@ -55,6 +62,21 @@ func TestParsing(t *testing.T) {
},
},
},
tCase{
Q: `a.b.c == 12 and name != "nandos"`,
E: []Query{
Query{
Field: "a.b.c",
Value: int64(12),
Op: itemEquals,
},
Query{
Field: "name",
Value: "nandos",
Op: itemNotEquals,
},
},
},
tCase{
Q: `a == 12 and name != "nan'dos"`,
E: []Query{