Fix SQL parsing of JSON strings
This commit is contained in:
parent
1a6ccf9070
commit
6417cd2c2c
2 changed files with 18 additions and 2 deletions
|
@ -928,10 +928,10 @@ func (s *scanner) scanObject(chp ...rune) (tok Token, lit string, val interface{
|
||||||
if ch := s.next(); ch == end && sub == 0 && qut == 0 {
|
if ch := s.next(); ch == end && sub == 0 && qut == 0 {
|
||||||
buf.WriteRune(ch)
|
buf.WriteRune(ch)
|
||||||
break
|
break
|
||||||
} else if ch == beg {
|
} else if ch == beg && qut == 0 {
|
||||||
sub++
|
sub++
|
||||||
buf.WriteRune(ch)
|
buf.WriteRune(ch)
|
||||||
} else if ch == end {
|
} else if ch == end && qut == 0 {
|
||||||
sub--
|
sub--
|
||||||
buf.WriteRune(ch)
|
buf.WriteRune(ch)
|
||||||
} else if ch == eof {
|
} else if ch == eof {
|
||||||
|
|
|
@ -1377,6 +1377,14 @@ func Test_Parse_Queries_Create(t *testing.T) {
|
||||||
Echo: AFTER,
|
Echo: AFTER,
|
||||||
}}},
|
}}},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
sql: `CREATE person CONTENT {"test":"{{{"}`,
|
||||||
|
res: &Query{Statements: []Statement{&CreateStatement{
|
||||||
|
What: []Expr{&Ident{"person"}},
|
||||||
|
Data: &ContentExpression{Data: map[string]interface{}{"test": "{{{"}},
|
||||||
|
Echo: AFTER,
|
||||||
|
}}},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
sql: `CREATE person CONTENT something`,
|
sql: `CREATE person CONTENT something`,
|
||||||
err: "Found `something` but expected `json`",
|
err: "Found `something` but expected `json`",
|
||||||
|
@ -1557,6 +1565,14 @@ func Test_Parse_Queries_Update(t *testing.T) {
|
||||||
Echo: AFTER,
|
Echo: AFTER,
|
||||||
}}},
|
}}},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
sql: `UPDATE person CONTENT {"test":"{{{"}`,
|
||||||
|
res: &Query{Statements: []Statement{&UpdateStatement{
|
||||||
|
What: []Expr{&Ident{"person"}},
|
||||||
|
Data: &ContentExpression{Data: map[string]interface{}{"test": "{{{"}},
|
||||||
|
Echo: AFTER,
|
||||||
|
}}},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
sql: `UPDATE person RETURN`,
|
sql: `UPDATE person RETURN`,
|
||||||
err: "Found `` but expected `NONE, BEFORE, AFTER`",
|
err: "Found `` but expected `NONE, BEFORE, AFTER`",
|
||||||
|
|
Loading…
Reference in a new issue