empty array detection before using IN operator in db queries