Django

Code

Ticket #9609 (closed: fixed)

Opened 8 months ago

Last modified 2 months ago

(Null)BooleanField does not clean data correctly for MySQL with all widgets

Reported by: psagers Assigned to: nobody
Milestone: 1.1 Component: Forms
Version: 1.0 Keywords:
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

MySQL represents boolean values as 0 and 1, as the BooleanField? documentation warns. This is not an issue when using a NullBooleanSelect? widget, as NullBooleanSelect? translates between model values and arbitrary integers for use in a form. However, not all choice widgets do this and thus they rely on the model values matching the widget values in order to populate initial widget state for rendering. The form field, in turn, must be able to clean the resulting form values. In order to support MySQL, therefore, (Null)BooleanField? must understand '0' and '1'.

Ticket 7753 added support for using HiddenWidget? with the boolean fields, which addresses the general problem of cleaning raw form values. The attached patch adds '0' and '1' to the list of recognized values.

Attachments

mysql_compat.diff (2.7 kB) - added by psagers on 11/16/08 01:32:38.

Change History

11/16/08 01:32:38 changed by psagers

  • attachment mysql_compat.diff added.

11/16/08 16:33:18 changed by psagers

  • needs_better_patch changed.
  • version changed from SVN to 1.0.
  • component changed from Uncategorized to Forms.
  • needs_tests changed.
  • needs_docs changed.

02/26/09 16:37:16 changed by jacob

  • stage changed from Unreviewed to Accepted.
  • milestone set to 1.1.

05/02/09 09:52:34 changed by russellm

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

(In [10660]) Fixed #9609 -- Modified the clean method of(Null)Boolean field to accept '1' and '0' as valid inputs. Thanks to psagers for the patch.

This is required to support the use of non-default form widgets such as RadioSelect? when the data comes from MySQL, which uses 1/0 to represent booleans.

05/02/09 09:56:36 changed by russellm

(In [10662]) Fixed #9609 -- Modified the clean method of(Null)Boolean field to accept '1' and '0' as valid inputs. Thanks to psagers for the patch.

This is required to support the use of non-default form widgets such as RadioSelect? when the data comes from MySQL, which uses 1/0 to represent booleans.

Merge of r10660 from trunk.


Add/Change #9609 ((Null)BooleanField does not clean data correctly for MySQL with all widgets)




Change Properties
Action