Fixed query generation bug when passing an empty array