Fix/5906 collection count is ignored when data empty

#5906 was caused by a small regression introduced by #5636