Enforce default RETURN value in sql parser

This commit is contained in:
Tobie Morgan Hitchcock 2017-02-14 19:23:53 +00:00
parent 3ffaec9265
commit 83a64c6c29
9 changed files with 11 additions and 13 deletions

View file

@ -87,7 +87,7 @@ func create(doc *item.Doc, ast *sql.CreateStatement) (out interface{}, err error
return
}
out = doc.Yield(ast.Echo, sql.AFTER)
out = doc.Yield(ast.Echo)
return

View file

@ -96,7 +96,7 @@ func delete(doc *item.Doc, ast *sql.DeleteStatement) (out interface{}, err error
}
out = doc.Yield(ast.Echo, sql.NONE)
out = doc.Yield(ast.Echo)
return

View file

@ -92,7 +92,7 @@ func update(doc *item.Doc, ast *sql.UpdateStatement) (out interface{}, err error
return
}
out = doc.Yield(ast.Echo, sql.AFTER)
out = doc.Yield(ast.Echo)
return

View file

@ -30,7 +30,7 @@ func (p *parser) parseCreateStatement() (stmt *CreateStatement, err error) {
return nil, err
}
if stmt.Echo, err = p.parseEcho(); err != nil {
if stmt.Echo, err = p.parseEcho(AFTER); err != nil {
return nil, err
}

View file

@ -39,7 +39,7 @@ func (p *parser) parseDeleteStatement() (stmt *DeleteStatement, err error) {
return nil, err
}
if stmt.Echo, err = p.parseEcho(); err != nil {
if stmt.Echo, err = p.parseEcho(NONE); err != nil {
return nil, err
}

View file

@ -14,7 +14,9 @@
package sql
func (p *parser) parseEcho() (exp Token, err error) {
func (p *parser) parseEcho(empty Token) (exp Token, err error) {
exp = empty
// The next token that we expect to see is a
// RETURN token, and if we don't find one then

View file

@ -48,7 +48,7 @@ func (p *parser) parseRelateStatement() (stmt *RelateStatement, err error) {
return nil, err
}
if stmt.Echo, err = p.parseEcho(); err != nil {
if stmt.Echo, err = p.parseEcho(AFTER); err != nil {
return nil, err
}

View file

@ -41,7 +41,7 @@ func (p *parser) parseUpdateStatement() (stmt *UpdateStatement, err error) {
return nil, err
}
if stmt.Echo, err = p.parseEcho(); err != nil {
if stmt.Echo, err = p.parseEcho(AFTER); err != nil {
return nil, err
}

View file

@ -18,11 +18,7 @@ import (
"github.com/abcum/surreal/sql"
)
func (this *Doc) Yield(output sql.Token, fallback sql.Token) (res interface{}) {
if output == 0 {
output = fallback
}
func (this *Doc) Yield(output sql.Token) (res interface{}) {
switch output {
case sql.ID: