Enable IF and RUN statements in MultStatements
This commit is contained in:
parent
6354d0ce2a
commit
2a74759a71
3 changed files with 14 additions and 1 deletions
|
@ -271,6 +271,9 @@ func (e *executor) operate(ctx context.Context, stm sql.Statement) (res []interf
|
|||
case *sql.IfStatement:
|
||||
res, err = e.executeIf(ctx, stm)
|
||||
|
||||
case *sql.RunStatement:
|
||||
res, err = e.executeRun(ctx, stm)
|
||||
|
||||
case *sql.InfoStatement:
|
||||
res, err = e.executeInfo(ctx, stm)
|
||||
|
||||
|
|
|
@ -120,6 +120,10 @@ func (e *executor) fetch(ctx context.Context, val interface{}, doc *data.Doc) (o
|
|||
|
||||
return nil, nil
|
||||
|
||||
case *sql.RunStatement:
|
||||
|
||||
return e.fetch(ctx, val.Expr, doc)
|
||||
|
||||
case *sql.IfStatement:
|
||||
|
||||
for k, v := range val.Cond {
|
||||
|
@ -188,6 +192,8 @@ func (e *executor) fetch(ctx context.Context, val interface{}, doc *data.Doc) (o
|
|||
for _, exp := range val.Expr {
|
||||
|
||||
switch exp := exp.(type) {
|
||||
default:
|
||||
out, err = e.fetch(ctx, exp, doc)
|
||||
case *sql.SelectStatement:
|
||||
out, err = e.fetchSelect(ctx, exp, doc)
|
||||
case *sql.CreateStatement:
|
||||
|
|
|
@ -605,9 +605,13 @@ func (p *parser) parseMult() (exp *MultExpression, err error) {
|
|||
|
||||
var stm Expr
|
||||
|
||||
tok, _, _ := p.mightBe(CREATE, UPDATE, DELETE, RELATE, INSERT, UPSERT)
|
||||
tok, _, _ := p.mightBe(IF, RUN, CREATE, UPDATE, DELETE, RELATE, INSERT, UPSERT)
|
||||
|
||||
switch tok {
|
||||
case IF:
|
||||
stm, err = p.parseIfel()
|
||||
case RUN:
|
||||
stm, err = p.parseRunStatement()
|
||||
case CREATE:
|
||||
p.buf.rw = true
|
||||
stm, err = p.parseCreateStatement()
|
||||
|
|
Loading…
Reference in a new issue