Bugs item #1501178, was opened at 2006-06-05 23:09
Message generated for change (Settings changed) made by phd
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1501178&group_id=74338
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: SQLObject from repository
>Status: Closed
>Resolution: Works For Me
Priority: 5
Submitted By: Chris Leonello (cleonello)
>Assigned to: Oleg Broytmann (phd)
Summary: integer and float values of 0 get converted to None
Initial Comment:
There is a problem with the validation/conversion of
integer and float columns. When creating objects with
IntCol and FloatCols, values of 0 are converted to
None. String values are converted properly, however.
An example:
class test(SQLObject):
fcol=FloatCol()
icol=IntCol()
t = test(fcol=3.2, icol=1)
print t
<test 10L fcol=3.2000000000000002 icol=1>
t = test(fcol=0.0, icol=0)
print t
<test 11L fcol=None icol=None>
t = test(fcol='0.0', icol='0')
print t
<test 14L fcol=0.0 icol=0>
I am using SQLObject rev 1675, python2.4, formencode
0.5.1, postgresql 8.1.
----------------------------------------------------------------------
>Comment By: Oleg Broytmann (phd)
Date: 2006-06-07 16:59
Message:
Logged In: YES
user_id=4799
You examples produce the followin results for me:
SQLite:
<test 1 fcol=3.2000000000000002 icol=1>
<test 2 fcol=0.0 icol=0> # No problem here, right?
Traceback (most recent call last):
File "./test1.py", line 23, in ?
t = test(fcol='0.0', icol='0')
File
"./SQLObject-0.7.1dev_r1684-py2.4.egg/sqlobject/declarative.py",
line 92, in _wrapper
File
"./SQLObject-0.7.1dev_r1684-py2.4.egg/sqlobject/main.py",
line 1197, in __init__
File
"./SQLObject-0.7.1dev_r1684-py2.4.egg/sqlobject/main.py",
line 1221, in _create
File
"./SQLObject-0.7.1dev_r1684-py2.4.egg/sqlobject/main.py",
line 1080, in set
File
"./SQLObject-0.7.1dev_r1684-py2.4.egg/sqlobject/col.py",
line 671, in from_python
formencode.api.Invalid: expected a float in the FloatCol
'fcol', got <type 'str'> '0.0' instead
Postgres 7.4:
<test 1L fcol=3.2000000000000002 icol=1>
<test 2L fcol=0.0 icol=0> # Ok?
Traceback (most recent call last):
File "./test1.py", line 23, in ?
t = test(fcol='0.0', icol='0')
File
"./SQLObject-0.7.1dev_r1684-py2.4.egg/sqlobject/declarative.py",
line 92, in _wrapper
File
"./SQLObject-0.7.1dev_r1684-py2.4.egg/sqlobject/main.py",
line 1197, in __init__
File
"./SQLObject-0.7.1dev_r1684-py2.4.egg/sqlobject/main.py",
line 1221, in _create
File
"./SQLObject-0.7.1dev_r1684-py2.4.egg/sqlobject/main.py",
line 1080, in set
File
"./SQLObject-0.7.1dev_r1684-py2.4.egg/sqlobject/col.py",
line 671, in from_python
formencode.api.Invalid: expected a float in the FloatCol
'fcol', got <type 'str'> '0.0' instead
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1501178&group_id=74338
|