#2365: [patch] models.FloatField should be renamed
-------------------------------+--------------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: adrian
Type: defect | Status: new
Priority: normal | Milestone:
Component: Database wrapper | Version:
Severity: normal | Resolution:
Keywords: |
-------------------------------+--------------------------------------------
Comment (by [EMAIL PROTECTED]):
New patch: this creates a separate models.DecimalField and
models.FloatField, and similar forms.DecimalField and forms.FloatField,
and finally, validators.IsValidDecimal and validators.IsValidFloat.
Motivation for this separation comes from the fact that floats lack
accuracy to represent decimals (e.g. for monetary values), and decimals
are a bad match for floats (e.g. for values with large magnitude
exponents). Following this motivation, IsValidDecimal does not accept
numbers with a literal exponent, although IsValidFloat does.
This patch also modifies the MySQL and Sqlite database wrappers (I
couldn't test against the others), to map DecimalField to NUMERIC, and
FloatField to DOUBLE (MySQL) or NUMERIC (Sqlite, which means it's really a
string, only collated as a number). The conversions table for MySQL is
also changed so that DECIMAL and NEWDECIMAL fields are always returned as
strings -- as the default behaviour is to return decimals if possible, or
else floats; and we never want a float where we expected a decimal.
Finally, this patch should work without the decimal module: if the decimal
module is available, then models.DecimalField attributes will be
decimal.Decimal instances; if not, then they will be strings. If the user
needs to perform arithmetic, then he can call float() and operate within
the accuracy limits of floats, but it's safer not to convert implicitly.
--
Ticket URL: <http://code.djangoproject.com/ticket/2365>
Django <http://code.djangoproject.org/>
The web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates
-~----------~----~----~----~------~----~------~--~---