Add tests for gql to sql compile

This commit is contained in:
Vikram Rangnekar
2019-03-24 18:16:03 -04:00
parent 0f5ce2f69d
commit b48a929538
8 changed files with 371 additions and 106 deletions

31
qcode/utils.go Normal file
View File

@ -0,0 +1,31 @@
package qcode
import (
"fmt"
"regexp"
"strings"
)
func NewBlacklist(list []string) *regexp.Regexp {
var bl *regexp.Regexp
if len(list) != 0 {
re := fmt.Sprintf("(?i)%s", strings.Join(list, "|"))
bl = regexp.MustCompile(re)
}
return bl
}
func NewFilterMap(filters map[string]string) FilterMap {
fm := make(FilterMap)
for k, v := range filters {
fil, err := CompileFilter(v)
if err != nil {
panic(err)
}
key := strings.ToLower(k)
fm[key] = fil
}
return fm
}