mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-19 22:28:45 +05:00
Replace with constants
This commit is contained in:
committed by
Dan Christian Bogos
parent
7e0ae18009
commit
c15d33e216
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user