Fixed omit query, backport #578