Null check for range query