[orm-devel] Numeric/float prob committing (was: Introduction, thanks and a couple of comments on the 0.7 release)

Eric Walstad orm-devel@mailman.tux4web.de
Fri, 6 Dec 2002 06:59:37 -0800 (PST)


Hi Diedrich,

--- Diedrich Vorberg <diedrich@tux4web.de> wrote:
> >> psycopg.ProgrammingError: ERROR: parser: parse error at or near "=<"
> >> UPDATE projects SET job_number='2002-057', [snip other columns],
> >> bid_price=<orm.columns._float instance at 0x8d5a5bc>, city='San
> >> Francisco'
> >> WHERE id=315
> 
> I don't seem to be able to reproduce this. Could you take a look at 
> the assignment of the new value? Do you assign a float number or a 
> column instance? Perhaps just cut and paste the code ...
So you are able to commit numerical data types to postgres?
The number is cast to a float before I try to commit it (see wxPython code
snippet below).  If you're not familiar with wxPython, the .GetValue()
methods return string data:
    def OnSave(self, event):
        # don't bother with the id
        self.project.job_number = self.job_number.GetValue()
        #Special Date handling
        if self.project_date.GetValue() != "":
            self.project.project_date = \
               Parser.DateFromString( \
               self.project_date.GetValue())
        self.project.name = self.name.GetValue()        
        self.project.contacts_id = \
            self.contacts_id.GetClientData( \
                self.contacts_id.GetSelection())
        self.project.project_type = \
            self.project_type.GetStringSelection()
        
        # TODO: Fix the problem committing floats!
        self.project.bid_price = float(self.bid_price.GetValue())

        self.project.address = self.address.GetValue()
        self.project.city = self.city.GetValue()
        self.project.state = self.state.GetValue()
        self.project.zip = self.zip.GetValue()
        if self.DoInsert:
            self.ds.insert(self.contact)                    
        # Commit the modified project to the database 
        self.ds.commit()

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com