#2231 closed defect (invalid)
Boolean fields don't honor 'default' parameter
Reported by: | Russell Keith-Magee | Owned by: | Russell Keith-Magee |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | |
Severity: | normal | Keywords: | boolean default |
Cc: | martinson.jacob@…, freakboy3742@… | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Jacob Martinson <martinson.jacob@…> reports that in the model:
class Response(models.Model): responded = models.BooleanField(default=False)
The postgresql table that gets created does not have a default value
for the "responded" column and I get a sql exception if I don't
manually set responded to 'f' when I save each new Response object.
Change History (6)
comment:1 by , 18 years ago
comment:2 by , 18 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Looks to be completely unrepeatable now (even by Jacob). Please reopen if it appears again.
comment:3 by , 16 years ago
Cc: | added |
---|---|
Resolution: | invalid |
Status: | closed → reopened |
It is repeatable:
Current trunk
cd django/trunk; svn update ... Aktualisiert zu Revision 9391.
django-admin startapp booltest # booltest/models.py from django.db import models class TestModel(models.Model): truth=models.BooleanField(default=False)
>django-admin.py sqlall booltest BEGIN; CREATE TABLE "booltest_testmodel" ( "id" serial NOT NULL PRIMARY KEY, "truth" boolean NOT NULL ) ; COMMIT;
DATABASE_ENGINE = 'postgresql_psycopg2'
I expected:
... "truth" boolean NOT NULL DEFAULT FALSE
comment:4 by , 16 years ago
Default isn't handled at the SQL level - it's handled at the model level.
comment:5 by , 16 years ago
Resolution: | → invalid |
---|---|
Status: | reopened → closed |
comment:6 by , 13 years ago
Cc: | removed |
---|---|
Easy pickings: | unset |
UI/UX: | unset |
Note:
See TracTickets
for help on using tickets.
Further investigation reveals that this might not actually be a problem - Follow the user mailing list thread ("Default value for boolean field") for more details.