Redesign config file architecture

This commit is contained in:
Vikram Rangnekar
2019-04-08 21:24:29 -04:00
parent e3660473cc
commit 2d02f2afda
6 changed files with 198 additions and 98 deletions

View File

@ -61,7 +61,8 @@ type Paging struct {
type ExpOp int
const (
OpAnd ExpOp = iota + 1
OpNop ExpOp = iota
OpAnd
OpOr
OpNot
OpEquals
@ -92,6 +93,8 @@ func (t ExpOp) String() string {
var v string
switch t {
case OpNop:
v = "op-nop"
case OpAnd:
v = "op-and"
case OpOr:
@ -333,7 +336,12 @@ func (com *Compiler) compileQuery(op *Operation) (*Query, error) {
}
}
if fil, ok := com.fm[selRoot.Table]; ok {
fil, ok := com.fm[selRoot.Table]
if !ok {
fil = com.fl
}
if fil != nil && fil.Op != OpNop {
if selRoot.Where != nil {
selRoot.Where = &Exp{Op: OpAnd, Children: []*Exp{fil, selRoot.Where}}
} else {
@ -788,6 +796,10 @@ func compileFilter(filter []string) (*Exp, error) {
var fl *Exp
com := &Compiler{}
if len(filter) == 0 {
return &Exp{Op: OpNop}, nil
}
for i := range filter {
node, err := ParseArgValue(filter[i])
if err != nil {