Update get_constraints with better comments
This commit is contained in:
parent
d5a7a3d6a8
commit
7702819441
|
@ -1328,9 +1328,20 @@ class BaseDatabaseIntrospection(object):
|
||||||
|
|
||||||
def get_constraints(self, cursor, table_name):
|
def get_constraints(self, cursor, table_name):
|
||||||
"""
|
"""
|
||||||
Returns {'cnname': {'columns': set(columns), 'primary_key': bool, 'unique': bool}}
|
Retrieves any constraints or keys (unique, pk, fk, check, index)
|
||||||
|
across one or more columns.
|
||||||
Both single- and multi-column constraints are introspected.
|
|
||||||
|
Returns a dict mapping constraint names to their attributes,
|
||||||
|
where attributes is a dict with keys:
|
||||||
|
* columns: List of columns this covers
|
||||||
|
* primary_key: True if primary key, False otherwise
|
||||||
|
* unique: True if this is a unique constraint, False otherwise
|
||||||
|
* foreign_key: (table, column) of target, or None
|
||||||
|
* check: True if check constraint, False otherwise
|
||||||
|
* index: True if index, False otherwise.
|
||||||
|
|
||||||
|
Some backends may return special constraint names that don't exist
|
||||||
|
if they don't name constraints of a certain type (e.g. SQLite)
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
|
||||||
"columns": [],
|
"columns": [],
|
||||||
"primary_key": False,
|
"primary_key": False,
|
||||||
"unique": False,
|
"unique": False,
|
||||||
"foreign_key": False,
|
"foreign_key": None,
|
||||||
"check": True,
|
"check": True,
|
||||||
"index": False,
|
"index": False,
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
|
||||||
"columns": list(columns),
|
"columns": list(columns),
|
||||||
"primary_key": primary,
|
"primary_key": primary,
|
||||||
"unique": unique,
|
"unique": unique,
|
||||||
"foreign_key": False,
|
"foreign_key": None,
|
||||||
"check": False,
|
"check": False,
|
||||||
"index": True,
|
"index": True,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue