refactor NULL handling for unique constraints