Opened 18 years ago
Closed 17 years ago
#4485 closed (fixed)
Can't set nullable DecimalField to null
| Reported by: | Owned by: | George Vilches | |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | dev |
| Severity: | Keywords: | DecimalField null None sprintsept14 easy-pickings | |
| Cc: | me@… | Triage Stage: | Ready for checkin |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Attached patch allows you to set a DecimalField where null=True to None, and have it save as a NULL in the database (like the other field types).
Attachments (3)
Change History (14)
by , 18 years ago
| Attachment: | decimalfield_null.diff added |
|---|
comment:1 by , 18 years ago
| Has patch: | set |
|---|---|
| Needs tests: | set |
| Triage Stage: | Unreviewed → Accepted |
Just needs some tests
comment:2 by , 18 years ago
| Owner: | changed from to |
|---|
by , 18 years ago
| Attachment: | decimalfield_null.2.diff added |
|---|
patch to allow DecimalField to contain NULL; regression tests included
comment:3 by , 18 years ago
| Needs tests: | unset |
|---|---|
| Triage Stage: | Accepted → Ready for checkin |
Moved "is None" test to _format() which will then return None rather than u for NULL values. This is consistent with the way NULL is handled for other fiends. Regression tests are included in the patch.
comment:4 by , 18 years ago
| Keywords: | sprintsept14 added |
|---|
comment:5 by , 18 years ago
| Triage Stage: | Ready for checkin → Accepted |
|---|
Oops. I thought I was supposed to change the stage. Changing back to "accepted."
comment:6 by , 18 years ago
| Cc: | added |
|---|
comment:7 by , 18 years ago
| Keywords: | easy-pickings added |
|---|---|
| Patch needs improvement: | set |
Looks good. You can remove the None test in get_db_prep_save now, since you've moved that logic to _format.
comment:8 by , 17 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
by , 17 years ago
| Attachment: | decimal_field_nullable_r7722.diff added |
|---|
Nullable field decimal patch updated to r7722.
comment:9 by , 17 years ago
| Patch needs improvement: | unset |
|---|---|
| Triage Stage: | Accepted → Ready for checkin |
Patch updated against r7722. Since this is a very simple patch and the unit tests still work fine, I'm bumping it to ready for checkin.
comment:10 by , 17 years ago
For anybody following the changes to the patch, I'm going to change the tests for checkin, since passing floats to a decimal field is not something that is supported. I'm also not amazingly happy with tests at this level (db_prep_save(), etc) since that's internal implementation details, rather than the functional effects. But it will do for now.
as described