Django

Code

Ticket #4485 (closed: fixed)

Opened 1 year ago

Last modified 3 months ago

Can't set nullable DecimalField to null

Reported by: sime <simon@quo.com.au> Assigned to: gav
Milestone: Component: Database layer (models, ORM)
Version: SVN Keywords: DecimalField null None sprintsept14 easy-pickings
Cc: me@andy.durdin.net Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

decimalfield_null.diff (0.5 kB) - added by sime <simon@quo.com.au> on 06/05/07 20:25:44.
as described
decimalfield_null.2.diff (1.2 kB) - added by tdterry on 09/14/07 14:12:51.
patch to allow DecimalField? to contain NULL; regression tests included
decimal_field_nullable_r7722.diff (1.2 kB) - added by gav on 06/22/08 20:52:32.
Nullable field decimal patch updated to r7722.

Change History

06/05/07 20:25:44 changed by sime <simon@quo.com.au>

  • attachment decimalfield_null.diff added.

as described

06/11/07 00:43:56 changed by SmileyChris

  • needs_better_patch changed.
  • has_patch set to 1.
  • stage changed from Unreviewed to Accepted.
  • needs_tests set to 1.
  • needs_docs changed.

Just needs some tests

09/14/07 09:46:00 changed by tdterry

  • owner changed from nobody to tdterry.

09/14/07 14:12:51 changed by tdterry

  • attachment decimalfield_null.2.diff added.

patch to allow DecimalField? to contain NULL; regression tests included

09/14/07 14:18:59 changed by tdterry

  • needs_tests deleted.
  • 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.

09/14/07 14:40:07 changed by tdterry

  • keywords changed from DecimalField null None to DecimalField null None sprintsept14.

09/14/07 15:41:07 changed by tdterry

  • stage changed from Ready for checkin to Accepted.

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

09/17/07 05:07:23 changed by durdinator

  • cc set to me@andy.durdin.net.

02/21/08 16:04:14 changed by SmileyChris

  • keywords changed from DecimalField null None sprintsept14 to DecimalField null None sprintsept14 easy-pickings.
  • needs_better_patch set to 1.

Looks good. You can remove the None test in get_db_prep_save now, since you've moved that logic to _format.

06/22/08 09:13:55 changed by gav

  • owner changed from tdterry to gav.
  • status changed from new to assigned.

06/22/08 20:52:32 changed by gav

  • attachment decimal_field_nullable_r7722.diff added.

Nullable field decimal patch updated to r7722.

06/22/08 20:59:26 changed by gav

  • needs_better_patch deleted.
  • 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.

06/30/08 04:59:50 changed 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.

06/30/08 06:39:17 changed by mtredinnick

  • status changed from assigned to closed.
  • resolution set to fixed.

Fixed in [7797].


Add/Change #4485 (Can't set nullable DecimalField to null)




Change Properties
Action