summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2013-08-10 23:58:12 +0100
committerAndrew Godwin <andrew@aeracode.org>2013-08-10 23:58:12 +0100
commit77028194415cb03b1ff2a85a86d806a0366bccff (patch)
tree591c31dddb2d447b2e663befc28f202a0c53d388
parentd5a7a3d6a80684caa8f5c3c7d5b454e3da1799a1 (diff)
Update get_constraints with better comments
-rw-r--r--django/db/backends/__init__.py17
-rw-r--r--django/db/backends/postgresql_psycopg2/introspection.py4
2 files changed, 16 insertions, 5 deletions
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py
index ec6081678b..771b9af59c 100644
--- a/django/db/backends/__init__.py
+++ b/django/db/backends/__init__.py
@@ -1328,9 +1328,20 @@ class BaseDatabaseIntrospection(object):
def get_constraints(self, cursor, table_name):
"""
- Returns {'cnname': {'columns': set(columns), 'primary_key': bool, 'unique': bool}}
-
- Both single- and multi-column constraints are introspected.
+ Retrieves any constraints or keys (unique, pk, fk, check, index)
+ across one or more columns.
+
+ 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
diff --git a/django/db/backends/postgresql_psycopg2/introspection.py b/django/db/backends/postgresql_psycopg2/introspection.py
index a816bb34d8..3e2574b0c1 100644
--- a/django/db/backends/postgresql_psycopg2/introspection.py
+++ b/django/db/backends/postgresql_psycopg2/introspection.py
@@ -169,7 +169,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
"columns": [],
"primary_key": False,
"unique": False,
- "foreign_key": False,
+ "foreign_key": None,
"check": True,
"index": False,
}
@@ -197,7 +197,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
"columns": list(columns),
"primary_key": primary,
"unique": unique,
- "foreign_key": False,
+ "foreign_key": None,
"check": False,
"index": True,
}