Closed eabili0 closed 4 years ago
Ok. I have pinned down the error is in the cast all other attributes to string
code section from ruller-dsl's conditionCode.
CONDITION AFTER REGEX FUNC: contains(group:102_202_state,input:state) and contains(group:102_203_ag,input:ag) and !contains(group:102_204_customerid_0,input:customerid) and !contains(group:102_204_customerid_1,input:customerid) and !contains(group:102_205_ag_state,input:ag_state) and randomPerc(38,input:customerid)
CONDITION AFTER CONCAT: contains(group:102_202_state,input:state) and contains(group:102_203_ag,input:ag) and !contains(group:102_204_customerid_0,input:customerid) and !contains(group:102_204_customerid_1,input:customerid) and !contains(group:102_205_ag_state,input:ag_state) and randomPerc(38,input:customerid)
CONDITION AFTER GROUP_REFERENCES TO STRING: groupContains("mobpf","102_202_state",input:state) and groupContains("mobpf","102_203_ag",input:ag) and !groupContains("mobpf","102_204_customerid_0",input:customerid) and !groupContains("mobpf","102_204_customerid_1",input:customerid) and !groupContains("mobpf","102_205_ag_state",input:ag_state) and randomPerc(38,input:customerid)
CONDITION AFTER RANDOM PERC: groupContains("mobpf","102_202_state",input:state) and groupContains("mobpf","102_203_ag",input:ag) and !groupContains("mobpf","102_204_customerid_0",input:customerid) and !groupContains("mobpf","102_204_customerid_1",input:customerid) and !groupContains("mobpf","102_205_ag_state",input:ag_state) and randomPerc(38,input:customerid,1234)
CONDITION AFTER NUMERIC COMPARISONS: groupContains("mobpf","102_202_state",input:state) and groupContains("mobpf","102_203_ag",input:ag) and !groupContains("mobpf","102_204_customerid_0",input:customerid) and !groupContains("mobpf","102_204_customerid_1",input:customerid) and !groupContains("mobpf","102_205_ag_state",input:ag_state) and randomPerc(38,input:customerid,1234)
CONDITION AFTER CAST STRING: groupContains("mobpf","102_202_state",input:state.(string)) and groupContains("mobpf","102_203_ag",input:ag.(string)) and !groupContains("mobpf","102_204_customerid_0",input:customerid.(string)) and !groupContains("mobpf","102_204_customerid_1",input:customerid.(string)) and !groupContains("mobpf","102_205_ag_state",input:ag.(string)_state) and randomPerc(38,input:customerid.(string),1234)
Ok. Found the error.
On line condition = strings.Replace(condition, "input:"+sm, fmt.Sprintf("input:%s.(string)", sm), -1)
, if sm
is also a prefix to any of other fields, it breaks them replacing the prefix with .(string)
.
@abilioesteves, what if you change the match regex to include , ) and \s? Something like: inputNameRegex2 := regexp.MustCompile("input:([a-z0-9-_\.]+)[,)\s]") Can you test it locally?
makes sense. will give it a try
@milhomens it worked! Had to change a little bit more than that, but it is now working!
PR #20
We got a little biased, so we forgot simple conditions like input:ag=='1234'. You probably need to add "=" to the regex.
@milhomens, ==
and !=
have now been added to the regex
any opinions on this @flaviostutz ?
Hello,
We have the following json rules file:
Ruller-DSL generates the following code for the condition of rule
Novo Teste - Piloto
:This code breaks on build because the
groupContains
onag_state
is matching onctx.Input["ag"]
and_state
is being weirdly appended toctx.Input["ag"].(string)
:Could you please help me verify what is causing this behaviour? Thank you!