Fixes problem with compiling queries with NOT expressions in them