Although this is possibly intentional, a null field is considered to be non-unique. This makes it impossible to create a cck field which should be "empty or containing a non-unique value" as any null values are considered repetitions of other null values.

This may be desirable, but would, in my view, be better managed by forcing the field to be non-null. Otherwise, make unique_field ignore comparisons where the comparison contains a null value.

Thanks, Stephen

Comments

arithmetric’s picture

Assigned: Unassigned » arithmetric
Status: Active » Fixed

Stephen,

Thanks for your insight on this. Since it's possible to make a field 'required' (meaning the field cannot be empty), it makes sense to me to change the behavior of unique field to not consider null/empty values as being duplicates of each other. I've made this change in the revision dated after 03/13/2008. Let me know how that works for you.

Thanks, Joe

scedwar’s picture

Good work. I'll update and report back.

However, can you do a new dev release as I can see the commit but there doesn't seem to be a release packaging up the changes. Am I missing something?

Thanks

arithmetric’s picture

The dev releases are automatically packaged every 12 hours. It should be available now.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

giorgio79’s picture

Version: 5.x-1.x-dev » 7.x-1.x-dev
Status: Closed (fixed) » Active

I seem to be getting this in the latest dev for 7x

johnv’s picture

Status: Active » Postponed (maintainer needs more info)

@giorgio79, I just enabled unique_field, and I do not get this error.
- enable unique_field
- set 1 field of 1 content type to be unique. All other settings not touched.
- set field tot be not required.
- save node with unique_field-field filled. ==> I get an error when using the same value twice.
- save node with nunique_field-field empty ==> no error when saving the second node with empty field.

Do you still get this error?

Coupon Code Swap’s picture

Issue summary: View changes

I am having an issue with this. I am using 7.x-1.0-rc1 and it does not seem to matter whether the field is required or not. In my case, I need to specify that the field is required. However, I do not want checking to take place for NULL values. I am using the ajax patch posted here:

https://drupal.org/node/1926346

If the field that is checked for uniqueness is left empty, a big long list of matching nodes is displayed (both with the ajax checking error message and with the regular message if a user attempts to submit the node), even though the field for the matching nodes contains values and thus the error should not be displayed. I would like to turn off checking when the field is left blank and just have a regular message that the field is required if a user attempts to submit a node and the required field was left empty.

Pravin Ajaaz’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)