Fix inference for predicates on has_many relationships