Opened 17 years ago

Closed 16 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: 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)

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

Download all attachments as: .zip

Change History (14)

by sime <simon@…>, 17 years ago

Attachment: decimalfield_null.diff added

as described

comment:1 by Chris Beaven, 17 years ago

Has patch: set
Needs tests: set
Triage Stage: UnreviewedAccepted

Just needs some tests

comment:2 by tdterry, 17 years ago

Owner: changed from nobody to tdterry

by tdterry, 17 years ago

Attachment: decimalfield_null.2.diff added

patch to allow DecimalField to contain NULL; regression tests included

comment:3 by tdterry, 17 years ago

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 by tdterry, 17 years ago

Keywords: sprintsept14 added

comment:5 by tdterry, 17 years ago

Triage Stage: Ready for checkinAccepted

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

comment:6 by durdinator, 17 years ago

Cc: me@… added

comment:7 by Chris Beaven, 16 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 George Vilches, 16 years ago

Owner: changed from tdterry to George Vilches
Status: newassigned

by George Vilches, 16 years ago

Nullable field decimal patch updated to r7722.

comment:9 by George Vilches, 16 years ago

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 by Malcolm Tredinnick, 16 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.

comment:11 by Malcolm Tredinnick, 16 years ago

Resolution: fixed
Status: assignedclosed

Fixed in [7797].

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