Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
arithmetric CreditAttribution: arithmetric commentedStephen,
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
Comment #2
scedwar CreditAttribution: scedwar commentedGood 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
Comment #3
arithmetric CreditAttribution: arithmetric commentedThe dev releases are automatically packaged every 12 hours. It should be available now.
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #5
giorgio79 CreditAttribution: giorgio79 commentedI seem to be getting this in the latest dev for 7x
Comment #6
johnv@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?
Comment #7
Coupon Code Swap CreditAttribution: Coupon Code Swap commentedI 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.
Comment #8
Pravin Ajaaz CreditAttribution: Pravin Ajaaz commented