Code

Opened 8 years ago

Closed 7 years ago

#1230 closed defect (invalid)

FloatField values in generated Sql have no standard string representation

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

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

Attachments (0)

Change History (1)

comment:1 Changed 7 years ago by SmileyChris

  • Resolution set to invalid
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.