So I have this chunk of code
eval matched=0 | foreach UF* [eval matched = if(like('<<FIELD>>',valMask),matched+1,matched) | eval Property = if(matched>=1,Property,null)]
Amusingly if the matched
variable equals 1, the Property
will get null value, when I explicity say that if it is bigger or equal than 1, the Property should remain with her original value.
Proof matched = 1
Thoughts on this ?
Thanks
So apparently, matched
inside the foreach
is still 0. Something like Lazy Evaluation, but I don't really know. Anyway.. this works
foreach UF* [eval matched = if(like('<<FIELD>>',valMask),matched+1,matched)] | eval Property = if(matched>=1,Property,null)
So apparently, matched
inside the foreach
is still 0. Something like Lazy Evaluation, but I don't really know. Anyway.. this works
foreach UF* [eval matched = if(like('<<FIELD>>',valMask),matched+1,matched)] | eval Property = if(matched>=1,Property,null)
The structure generally looks ok, so I'm kind of reaching here. Any chance Property
was null before the second half of the foreach
ran? If you remove the second eval
clause, is Property
always populated?
The only possibility I'm seeing is that matched
is still 0 inside the foreach
. Like a lazy interation
I removed the eval clause, and all the Properties
get populated..
Can you try
eval matched=0 | foreach UF* [eval matched = if(like('<<FIELD>>',valMask),matched+1,matched) ]| foreach UF* [eval Property=if(matched>=1,Property,null)]
Same result.. What was your reasoning ?