diff --git a/sql/scanner.go b/sql/scanner.go index 4474b6e6..b10f4d3a 100644 --- a/sql/scanner.go +++ b/sql/scanner.go @@ -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 { buf.WriteRune(ch) break - } else if ch == beg { + } else if ch == beg && qut == 0 { sub++ buf.WriteRune(ch) - } else if ch == end { + } else if ch == end && qut == 0 { sub-- buf.WriteRune(ch) } else if ch == eof { diff --git a/sql/sql_test.go b/sql/sql_test.go index bdecee11..1b429416 100644 --- a/sql/sql_test.go +++ b/sql/sql_test.go @@ -1377,6 +1377,14 @@ func Test_Parse_Queries_Create(t *testing.T) { 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`, err: "Found `something` but expected `json`", @@ -1557,6 +1565,14 @@ func Test_Parse_Queries_Update(t *testing.T) { 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`, err: "Found `` but expected `NONE, BEFORE, AFTER`",