Handle null values in prepared queries properly