Author: mtredinnick
Date: 2011-08-24 22:44:18 -0700 (Wed, 24 Aug 2011)
New Revision: 16681

Modified:
   django/trunk/django/core/management/validation.py
Log:
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).

Modified: django/trunk/django/core/management/validation.py
===================================================================
--- django/trunk/django/core/management/validation.py   2011-08-24 12:30:59 UTC 
(rev 16680)
+++ django/trunk/django/core/management/validation.py   2011-08-25 05:44:18 UTC 
(rev 16681)
@@ -39,7 +39,11 @@
                 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:

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to