Fix to query parsing