Opened 19 years ago

Closed 18 years ago

#1230 closed defect (invalid)

FloatField values in generated Sql have no standard string representation

Reported by: gp.ciceri@… Owned by: Adrian Holovaty
Component: Core (Other) Version: dev
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In FloatField class definition there's no value string representation to put the float into the database,

so rounding problems may occur: perhaps a simple helper method like this can help.

def get_db_prep_save(self, value):
        "Returns field's value prepared for saving into a database."
        if self.max_digits == None: self.max_digits = 12
        if self.decimal_places == None: self.decimal_places = 4
        fmt = "%%%s.%sf" % (self.max_digits, self.decimal_places)
        return fmt % value

Thanks for your patience
/gp

Change History (1)

comment:1 by Chris Beaven, 18 years ago

Resolution: invalid
Status: newclosed

Rounding problems occur even with string formatting in python. Solution is decimal, but that's going around in enough other patches right now that I'm going to just close this one.

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