mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #14204 -- Enforced SQLite foreign key constraints.
Thanks Tim Graham for contributing to the patch and Simon Charette for advice and review.
This commit is contained in:
@@ -289,4 +289,17 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
|
||||
"check": False,
|
||||
"index": False,
|
||||
}
|
||||
# Get foreign keys
|
||||
cursor.execute('PRAGMA foreign_key_list(%s)' % self.connection.ops.quote_name(table_name))
|
||||
for row in cursor.fetchall():
|
||||
# Remaining on_update/on_delete/match values are of no interest here
|
||||
id_, seq, table, from_, to = row[:5]
|
||||
constraints['fk_%d' % id_] = {
|
||||
'columns': [from_],
|
||||
'primary_key': False,
|
||||
'unique': False,
|
||||
'foreign_key': (table, to),
|
||||
'check': False,
|
||||
'index': False,
|
||||
}
|
||||
return constraints
|
||||
|
||||
Reference in New Issue
Block a user