Opened 8 years ago

Closed 7 years ago

#4485 closed (fixed)

Can't set nullable DecimalField to null

Reported by: sime <simon@…> Owned by: gav
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@…> 8 years ago.
as described
decimalfield_null.2.diff (1.2 KB) - added by tdterry 8 years ago.
patch to allow DecimalField to contain NULL; regression tests included
decimal_field_nullable_r7722.diff (1.2 KB) - added by gav 7 years ago.
Nullable field decimal patch updated to r7722.

Download all attachments as: .zip

Change History (14)

Changed 8 years ago by sime <simon@…>

as described

comment:1 Changed 8 years ago by SmileyChris

  • Has patch set
  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Just needs some tests

comment:2 Changed 8 years ago by tdterry

  • Owner changed from nobody to tdterry

Changed 8 years ago by tdterry

patch to allow DecimalField to contain NULL; regression tests included

comment:3 Changed 8 years ago by tdterry

  • Needs tests unset
  • Triage Stage changed from Accepted to 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 Changed 8 years ago by tdterry

  • Keywords sprintsept14 added

comment:5 Changed 8 years ago by tdterry

  • Triage Stage changed from Ready for checkin to Accepted

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

comment:6 Changed 8 years ago by durdinator

  • Cc me@… added

comment:7 Changed 8 years ago by SmileyChris

  • 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 7 years ago by gav

  • Owner changed from tdterry to gav
  • Status changed from new to assigned

Changed 7 years ago by gav

Nullable field decimal patch updated to r7722.

comment:9 Changed 7 years ago by gav

  • Patch needs improvement unset
  • Triage Stage changed from Accepted to 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 Changed 7 years ago by mtredinnick

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 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed in [7797].

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