Opened 9 years ago

Closed 8 years ago

#4485 closed (fixed)

Can't set nullable DecimalField to null

Reported by: sime <simon@…> Owned by: George Vilches
Component: Database layer (models, ORM) Version: master
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: UI/UX:

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)

decimalfield_null.diff (546 bytes) - added by sime <simon@…> 9 years ago.
as described
decimalfield_null.2.diff (1.2 KB) - added by tdterry 9 years ago.
patch to allow DecimalField to contain NULL; regression tests included
decimal_field_nullable_r7722.diff (1.2 KB) - added by George Vilches 8 years ago.
Nullable field decimal patch updated to r7722.

Download all attachments as: .zip

Change History (14)

Changed 9 years ago by sime <simon@…>

Attachment: decimalfield_null.diff added

as described

comment:1 Changed 9 years ago by Chris Beaven

Has patch: set
Needs documentation: unset
Needs tests: set
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

Just needs some tests

comment:2 Changed 9 years ago by tdterry

Owner: changed from nobody to tdterry

Changed 9 years ago by tdterry

Attachment: decimalfield_null.2.diff added

patch to allow DecimalField to contain NULL; regression tests included

comment:3 Changed 9 years ago by tdterry

Needs tests: unset
Triage Stage: AcceptedReady 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 Changed 9 years ago by tdterry

Keywords: sprintsept14 added

comment:5 Changed 9 years ago by tdterry

Triage Stage: Ready for checkinAccepted

Oops. I thought I was supposed to change the stage. Changing back to "accepted."

comment:6 Changed 9 years ago by durdinator

Cc: me@… added

comment:7 Changed 9 years ago by Chris Beaven

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 Changed 8 years ago by George Vilches

Owner: changed from tdterry to George Vilches
Status: newassigned

Changed 8 years ago by George Vilches

Nullable field decimal patch updated to r7722.

comment:9 Changed 8 years ago by George Vilches

Patch needs improvement: unset
Triage Stage: AcceptedReady 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 Changed 8 years ago by Malcolm Tredinnick

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.

comment:11 Changed 8 years ago by Malcolm Tredinnick

Resolution: fixed
Status: assignedclosed

Fixed in [7797].

Note: See TracTickets for help on using tickets.
Back to Top