From: Josu O. <jo...@ub...> - 2004-11-04 16:57:35
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi all, i don't know if this is discussed. I'm trying to use SelectResults.sum to get the total for a column of floats. I think that it is trying to convert the result to an integer. Example: #------------- from sqlobject import * class Invoice(SQLObject): ~ provider = StringCol() ~ total = FloatCol() conn = SQLiteConnection(':memory:') Invoice._connection = conn Invoice.createTable() Invoice(provider='A', total=3.27) Invoice(provider='B', total=9.63) q = Invoice.select() print q.sum(Invoice.q.total) #---------------------- gets: - ------------------------- Traceback (most recent call last): ~ File "sql_sum_test.py", line 19, in ? ~ print q.sum(Invoice.q.total) ~ File "/usr/lib/python2.2/site-packages/sqlobject/main.py", line 1271, in sum ~ return self.accumulate(expression) ~ File "/usr/lib/python2.2/site-packages/sqlobject/main.py", line 1251, in accumulate ~ return conn.accumulateSelect(self,expression) ~ File "/usr/lib/python2.2/site-packages/sqlobject/dbconnection.py", line 248, in accumulateSelect ~ val = int(self.queryOne(q)[0]) ValueError: invalid literal for int(): 12.9 - ------------------------- (SQLObject version in 0.6) is this a bug or a feature? - -- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFBil9B5ju4HVxhuqQRAjcTAKDXtSrCYLzR3/EeQ+iO7gMlTmyATgCfYpsM vShKUUQ9kocy22toP9D2pIc= =xHKA -----END PGP SIGNATURE----- |