Subject Order of operations - AND boolean operator
Author Rick Debay
The field f.ID is alphanumeric, it can contain many types of data and
the data type is described by f.ID_QUALIFIER .
The problem is that Firebird is always evaluating "f.ID =" which throws
an exception when f.ID contains non-numeric characters and b.ID_TYPE_*
is numeric.

FROM FOO f
JOIN BAR b ON
((f.ID_QUALIFIER = 1) AND f.ID = b.ID_TYPE_1) OR
((f.ID_QUALIFIER = 2) AND f.ID = b.ID_TYPE_2

I've worked around it by replacing b.ID_TYPE1 with

(CASE WHEN f.ID_QUALIFIER = 1 THEN CAST(f.ID AS NUMERIC(10,0)) ELSE NULL
END)

Which in my opinion is quite the hack. How can I get the QUALIFIER test
to occur first?