Using MetaPipe (*|) as in-filter separator

This commit is contained in:
DanB
2017-11-14 08:43:11 +01:00
parent 62d875c221
commit 239b5678dc
2 changed files with 2 additions and 7 deletions

View File

@@ -147,7 +147,7 @@ const (
CSV_SEP = ','
FALLBACK_SEP = ';'
INFIELD_SEP = ";"
SUBFIELD_SEP = "|"
MetaPipe = "*|"
FIELDS_SEP = ","
InInFieldSep = ":"
STATIC_HDRVAL_SEP = "::"

View File

@@ -36,7 +36,7 @@ func NewRSRField(fldStr string) (fld *RSRField, err error) {
return nil, fmt.Errorf("Invalid FilterStartValue in string: %s", fldStr)
}
fltrVal := fldStr[fltrStart+1 : len(fldStr)-1]
filters, err = ParseRSRFilters(fltrVal, SUBFIELD_SEP)
filters, err = ParseRSRFilters(fltrVal, MetaPipe)
if err != nil {
return nil, fmt.Errorf("Invalid FilterValue in string: %s, err: %s", fltrVal, err.Error())
}
@@ -147,16 +147,12 @@ func (rsrf *RSRField) RegexpMatched() bool { // Investigate whether we had a reg
}
func (rsrf *RSRField) FilterPasses(value string) bool {
fmt.Printf("RSRField: %s, filterPasses value: <%q>\n", ToJSON(rsrf), value)
if len(rsrf.filters) == 0 { // No filters
return true
}
parsedVal := rsrf.ParseValue(value)
fmt.Printf("parsedVal: %s\n", parsedVal)
filterPasses := false
fmt.Printf("having filters: %s, len(filters): %d\n", ToJSON(rsrf.filters), len(rsrf.filters))
for _, fltr := range rsrf.filters {
fmt.Printf("Checking filter: %s")
if fltr.Pass(parsedVal) {
filterPasses = true
}
@@ -194,7 +190,6 @@ type RSRFilter struct {
}
func (rsrFltr *RSRFilter) Pass(val string) bool {
fmt.Printf("Filter with rule: %s, parsing val: %q\n", rsrFltr.filterRule, val)
if rsrFltr.filterRule == "" {
return !rsrFltr.negative
}