Fix for null pointer if the query is null.