[BZ 1069545] Fix queries related to subcategories.