#1459·eve

unique and nullable

Author: xibrizCreated Nov 19, 2021Updated Jul 7, 2023

Expected Behavior

When a field is marked as unique and nullable (optional) I would expect that no duplicate values are allowed except null/None.

A wourkaround could be to omit the default None and omit the field. But would it not make more sense to allow multiple null values?

schema =  {
    'optional_unique_value': {
        'type': 'string',
        'default': None,
        'unique': True,
        'nullable': True,
    }
}

Actual Behavior

An error message is given: "value 'None' is not unique"

Environment

  • Python version: 3.8.10
  • Eve version: 1.1.5