diff --git a/sql/ast.go b/sql/ast.go index 9fbaab2e..41b3a194 100644 --- a/sql/ast.go +++ b/sql/ast.go @@ -178,7 +178,6 @@ type DefineRulesStatement struct { What []string `cork:"-" codec:"-"` When []string `cork:"-" codec:"-"` Rule string `cork:"rule" codec:"rule"` - Code string `cork:"code" codec:"code"` Cond []Expr `cork:"cond" codec:"cond"` } diff --git a/sql/rules.go b/sql/rules.go index fdb7bf0e..6e689b60 100644 --- a/sql/rules.go +++ b/sql/rules.go @@ -53,18 +53,12 @@ func (p *parser) parseDefineRulesStatement() (stmt *DefineRulesStatement, err er return nil, &ParseError{Found: "", Expected: []string{"SELECT", "CREATE", "UPDATE", "DELETE", "RELATE"}} } - if tok, _, err := p.shouldBe(ACCEPT, REJECT, CUSTOM); err != nil { + if _, stmt.Rule, err = p.shouldBe(ACCEPT, REJECT); err != nil { return nil, err - } else { - - stmt.Rule = tok.String() - - if p.is(tok, CUSTOM) { - if stmt.Code, err = p.parseScript(); err != nil { - return nil, err - } - } + } + if stmt.Cond, err = p.parseCond(); err != nil { + return nil, err } if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { diff --git a/sql/sql_test.go b/sql/sql_test.go index af147dda..26b4552e 100644 --- a/sql/sql_test.go +++ b/sql/sql_test.go @@ -1364,7 +1364,7 @@ func Test_Parse_Queries_Define(t *testing.T) { }, { sql: `DEFINE RULES ON person FOR select, create, update, delete`, - err: "Found `` but expected `ACCEPT, REJECT, CUSTOM`", + err: "Found `` but expected `ACCEPT, REJECT`", }, { sql: `DEFINE RULES ON person FOR select, create, update, delete ACCEPT`, @@ -1387,24 +1387,11 @@ func Test_Parse_Queries_Define(t *testing.T) { }}}, }, { - sql: `DEFINE RULES ON person FOR select, create, update, delete REJECT something`, + sql: `DEFINE RULES ON person FOR select, create, update, delete ACCEPT something`, err: "Found `something` but expected `EOF, ;`", }, { - sql: `DEFINE RULES ON person FOR select, create, update, delete CUSTOM`, - err: "Found `` but expected `js/lua script`", - }, - { - sql: `DEFINE RULES ON person FOR select, create, update, delete CUSTOM "return true"`, - res: &Query{Statements: []Statement{&DefineRulesStatement{ - What: []string{"person"}, - When: []string{"SELECT", "CREATE", "UPDATE", "DELETE"}, - Rule: "CUSTOM", - Code: "return true", - }}}, - }, - { - sql: `DEFINE RULES ON person FOR select, create, update, delete CUSTOM "return true" something`, + sql: `DEFINE RULES ON person FOR select, create, update, delete REJECT something`, err: "Found `something` but expected `EOF, ;`", }, // ----------------------------------------------------------------------