I find that under some cercumstances a column declared as a certain
type can return a different type as shown in the following sample code,
tested with SQLObject 0.6.0
The test table, with PostgreSQL 7.4.6:
CREATE TABLE test
The test script:
id int4 NOT NULL DEFAULT nextval('test_id_seq'::text),
number int2 NOT NULL,
CONSTRAINT pkey PRIMARY KEY (id)
ALTER TABLE test OWNER TO test;
from sqlobject import *
While I would expect the result to be all <type 'int'>, the
actuall output is:
__connection__ = 'postgres://test:test@localhost/test?debug=0'
number = IntCol()
for i in [3, 5, 8]:
test(number = i)
i = test.select(test.q.number == 8)
i.number = '10'
results = test.select()
for r in results:
print r.number, type(r.number)
3 <type 'int'>
It seems that sqlobject has remembered that the type of column 'number'
was set to '10', a string type, though I thought IntCol should take
care of converting the string to int before sending it to the SQL
5 <type 'int'>
10 <type 'str'>
I think this kind of inconsistency of column return type will cause
great confusion to the programms that use sqlobject and should be fixed.