Added slightly hacky short cut evaluation of logical and on the sql level