Author: mtredinnick
Date: 2008-07-21 23:49:32 -0500 (Mon, 21 Jul 2008)
New Revision: 8050

Modified:
   django/trunk/django/db/models/fields/__init__.py
Log:
To ensure that a model BooleanField has an explicit value set (and since it's
not required, by default), set the default properly in the constructor.

This code can be simplified when/if we resolve the
BooleanField/NullBooleanField overlap, but the current stuff is backwards
compatible. This would previously cause SQL errors on PostgreSQL and
interesting failures in subtle ways on MySQL and SQLite.


Modified: django/trunk/django/db/models/fields/__init__.py
===================================================================
--- django/trunk/django/db/models/fields/__init__.py    2008-07-22 03:44:48 UTC 
(rev 8049)
+++ django/trunk/django/db/models/fields/__init__.py    2008-07-22 04:49:32 UTC 
(rev 8050)
@@ -477,6 +477,8 @@
 class BooleanField(Field):
     def __init__(self, *args, **kwargs):
         kwargs['blank'] = True
+        if 'default' not in kwargs and not kwargs.get('null'):
+            kwargs['default'] = False
         Field.__init__(self, *args, **kwargs)
 
     def get_internal_type(self):


--~--~---------~--~----~------------~-------~--~----~
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