pyeve / eve

REST API framework designed for human beings

Home Page:https://python-eve.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unique and nullable

xibriz opened this issue · comments

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

Could it be possible to remove the unique value and run the a check the application's logic?