diff options
author | Simon Charette <charette.s@gmail.com> | 2018-08-05 22:30:44 -0400 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2018-11-13 17:57:27 -0500 |
commit | db13bca60a6758d5fe63eeb01c00c3f54f650715 (patch) | |
tree | e1c3620032623488f2dac8320e3e646ed18cef1a /django/db/backends/sqlite3/introspection.py | |
parent | 8eae094638acf802c8047b341d126d94bc9b45a3 (diff) | |
download | django-db13bca60a6758d5fe63eeb01c00c3f54f650715.tar.gz |
Fixed #29641 -- Added support for unique constraints in Meta.constraints.
This constraint is similar to Meta.unique_together but also allows
specifying a name.
Co-authored-by: Ian Foote <python@ian.feete.org>
Diffstat (limited to 'django/db/backends/sqlite3/introspection.py')
-rw-r--r-- | django/db/backends/sqlite3/introspection.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/django/db/backends/sqlite3/introspection.py b/django/db/backends/sqlite3/introspection.py index 47ca25a78a..4f4a54eacf 100644 --- a/django/db/backends/sqlite3/introspection.py +++ b/django/db/backends/sqlite3/introspection.py @@ -260,6 +260,15 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): name_token = next_ttype(sqlparse.tokens.Literal.String.Symbol) name = name_token.value[1:-1] token = next_ttype(sqlparse.tokens.Keyword) + if token.match(sqlparse.tokens.Keyword, 'UNIQUE'): + constraints[name] = { + 'unique': True, + 'columns': [], + 'primary_key': False, + 'foreign_key': False, + 'check': False, + 'index': False, + } if token.match(sqlparse.tokens.Keyword, 'CHECK'): # Column check constraint if name is None: |