fix: rewrite the sql args and variables codebase to use expression values

This commit is contained in:
Vikram Rangnekar
2020-05-26 19:41:28 -04:00
parent f63e270c73
commit 2241364d00
35 changed files with 397 additions and 555 deletions

View File

@ -1,7 +1,6 @@
package qcode
import (
"regexp"
"sort"
"strings"
)
@ -46,8 +45,7 @@ type TRConfig struct {
}
type trval struct {
readOnly bool
query struct {
query struct {
limit string
fil *Exp
filNU bool
@ -132,12 +130,3 @@ func mapToList(m map[string]string) []string {
sort.Strings(list)
return list
}
var varRe = regexp.MustCompile(`\$([a-zA-Z0-9_]+)`)
func parsePresets(m map[string]string) map[string]string {
for k, v := range m {
m[k] = varRe.ReplaceAllString(v, `{{$1}}`)
}
return m
}

View File

@ -170,7 +170,6 @@ const (
)
type Compiler struct {
db bool // default block tables if not defined in anon role
tr map[string]map[string]*trval
bl map[string]struct{}
}
@ -227,7 +226,7 @@ func (com *Compiler) AddRole(role, table string, trc TRConfig) error {
return err
}
trv.insert.cols = listToMap(trc.Insert.Columns)
trv.insert.psmap = parsePresets(trc.Insert.Presets)
trv.insert.psmap = trc.Insert.Presets
trv.insert.pslist = mapToList(trv.insert.psmap)
trv.insert.block = trc.Insert.Block
@ -237,7 +236,7 @@ func (com *Compiler) AddRole(role, table string, trc TRConfig) error {
return err
}
trv.update.cols = listToMap(trc.Update.Columns)
trv.update.psmap = parsePresets(trc.Update.Presets)
trv.update.psmap = trc.Update.Presets
trv.update.pslist = mapToList(trv.update.psmap)
trv.update.block = trc.Update.Block