BZ-1019708: fixing NPE on queries with no results