diff --git a/config/dataprovider.go b/config/dataprovider.go index 49af848d2..0b2883279 100644 --- a/config/dataprovider.go +++ b/config/dataprovider.go @@ -88,9 +88,9 @@ func (objDP *ObjectDP) FieldAsInterface(fldPath []string) (data interface{}, err var prevFld string for _, fld := range fldPath { var slctrStr string - if splt := strings.Split(fld, "["); len(splt) != 1 { // check if we have selector + if splt := strings.Split(fld, utils.IdxStart); len(splt) != 1 { // check if we have selector fld = splt[0] - if splt[1][len(splt[1])-1:] != "]" { + if splt[1][len(splt[1])-1:] != utils.IdxEnd { return nil, fmt.Errorf("filter rule <%s> needs to end in ]", splt[1]) } slctrStr = splt[1][:len(splt[1])-1] // also strip the last ] @@ -98,7 +98,7 @@ func (objDP *ObjectDP) FieldAsInterface(fldPath []string) (data interface{}, err if prevFld == utils.EmptyString { prevFld += fld } else { - prevFld += "." + fld + prevFld += utils.NestingSep + fld } // check if we take the current path from cache @@ -115,7 +115,7 @@ func (objDP *ObjectDP) FieldAsInterface(fldPath []string) (data interface{}, err // change the obj to be the current data and continue the processing objDP.obj = data if slctrStr != utils.EmptyString { //we have selector so we need to do an aditional get - prevFld += "[" + slctrStr + "]" + prevFld += utils.IdxStart + slctrStr + utils.IdxEnd // check if we take the current path from cache if data, has = objDP.getCache(prevFld); !has { if data, err = utils.ReflectFieldMethodInterface(objDP.obj, slctrStr); err != nil { // take the object the field for current path @@ -132,7 +132,7 @@ func (objDP *ObjectDP) FieldAsInterface(fldPath []string) (data interface{}, err } //add in cache the initial path - objDP.setCache(strings.Join(fldPath, "."), data) + objDP.setCache(strings.Join(fldPath, utils.NestingSep), data) return } diff --git a/engine/filters.go b/engine/filters.go index 8685bb439..b684a0761 100644 --- a/engine/filters.go +++ b/engine/filters.go @@ -610,7 +610,7 @@ func (fS *FilterS) getFieldNameDataProvider(initialDP config.DataProvider, field //same of fieldName : ~*accounts.1001.BalanceMap.*monetary[0].Value // split the field name in 3 parts // fieldNameType (~*accounts), accountID(1001) and quried part (BalanceMap.*monetary[0].Value) - splitFldName := strings.SplitN(*fieldName, ".", 3) + splitFldName := strings.SplitN(*fieldName, utils.NestingSep, 3) if len(splitFldName) != 3 { return nil, fmt.Errorf("invalid fieldname <%s>", *fieldName) }