Test for queries with constraints.