Skip to content

Commit

Permalink
Added a special case to the unique validator for null/None
Browse files Browse the repository at this point in the history
  • Loading branch information
nightkr committed Oct 21, 2012
1 parent 820c75b commit ee18734
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions flask_admin/contrib/sqlamodel/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ def __init__(self, db_session, model, column, message=None):

def __call__(self, form, field):
try:
if field.data is None: # Most RDMBS treat all nulls as unique
return

obj = (self.db_session.query(self.model)
.filter(self.column == field.data).one())

Expand Down

0 comments on commit ee18734

Please sign in to comment.