Fixed bug when added scalar functions are used in WHERE clause