summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2011-08-25 05:44:18 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2011-08-25 05:44:18 +0000
commit20473057d13ac3e774ae29a1557ce4d18e7cdce6 (patch)
treeda726e20a24bb1e1a4e7f1757713266bcef0bf5a
parenta3fd9cf288e71b9c8e5fb6479eda3d33bc0a9d65 (diff)
Modify validity check from r16678 slightly to work with Oracle.
We now skip this particular check on Oracle backends. Change is based on a backend feature check, so it also works with other backends that may treat NULL as equal to an empty string. Fixes #16694 (with luck). git-svn-id: http://code.djangoproject.com/svn/django/trunk@16681 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/management/validation.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/django/core/management/validation.py b/django/core/management/validation.py
index c13b19df97..3cb2e345e8 100644
--- a/django/core/management/validation.py
+++ b/django/core/management/validation.py
@@ -39,7 +39,11 @@ def get_validation_errors(outfile, app=None):
e.add(opts, '"%s": You can\'t use "id" as a field name, because each model automatically gets an "id" field if none of the fields have primary_key=True. You need to either remove/rename your "id" field or add primary_key=True to a field.' % f.name)
if f.name.endswith('_'):
e.add(opts, '"%s": Field names cannot end with underscores, because this would lead to ambiguous queryset filters.' % f.name)
- if f.primary_key and f.null:
+ if (f.primary_key and f.null and
+ not connection.features.interprets_empty_strings_as_nulls):
+ # We cannot reliably check this for backends like Oracle which
+ # consider NULL and '' to be equal (and thus set up
+ # character-based fields a little differently).
e.add(opts, '"%s": Primary key fields cannot have null=True.' % f.name)
if isinstance(f, models.CharField):
try: