evaluating unlang IF with sql results

Phil Mayers p.mayers at imperial.ac.uk
Fri Jun 14 15:16:36 CEST 2013

On 14/06/13 13:29, Bill Schoolfield wrote:
> Actually this particular issue was the parenthesis around the number. I
> had added
> them in the expression to make sure the math occurred before the logical
> comparison.
> Without them though, unlang's IF seems to evaluate the first expression
> (a subtraction)
> and ignores things afterwards. So the IF always evaluated to true.

I'm not sure I understand this. But the current unlang parser can be a 
bit picky.

> I've concluded that the use of IF with multiple expressions won't work.
> So I have move
> this logic to perl.

There are other options. Specifically I often think it's better to 
expand to intermediate variables, then do logic on them:

update request {
   Tmp-Integer-0 := "%{expr: ...}"
   Tmp-Integer-1 := "%{expr: ...}"
if (Tmp-Integer-0 > Tmp-Integer-1) {

More information about the Freeradius-Users mailing list