Fix #2333

Prevent match all queries from overriding inherited query, closes #2333