Re: [Modeling-users] SQLite, problemas with Floats
Status: Abandoned
Brought to you by:
sbigaret
From: Sebastien B. <sbi...@us...> - 2003-09-17 11:38:36
|
"Ernesto Revilla" <er...@si...> wrote: > Ok, I've tracked down this and see the following issue: >=20 > In DatabaseContext.py, near line 1540, the following two lines appear: >=20 > if value and attr.type() =3D=3D 'DateTime': > value=3Dattr.convertStringToAttributeType(value) >=20 > So we only do type conversion if attr.type() =3D=3D 'DateTime' and value = is not empty ??? > Is this an optimization? >=20 > Shouldn't we force a conversion to Python types whenver possible? Should = this work be done by the database layer (perhaps we need custom conversions= depending on the database)? Usually these type conversions are done by the python adaptors --but right, everything in sqlite is string, but I can't remeber how pysqlite handles this, and I can't test this here. I've got to check this, especially why this is not catched by the unittests; I'll have a look at it this evening and will report with further details then. -- S=E9bastien. > ----- Original Message -----=20 > From: "Ernesto Revilla" <er...@si...> > To: "modeling-users" <mod...@li...> > Sent: Wednesday, September 17, 2003 1:31 AM > Subject: [Modeling-users] SQLite, problemas with Floats >=20 >=20 > Hi again (sorry for the attack), >=20 > I'm using Modeling 0.9-pre15 and sqlite 2.8.6 >=20 > When I do a fetch for objects with float attributes, these are string and= not float. Say: > .... > >>> accounts=3Dec.fetch('Account') > >>> accounts[0].getAmount() > '0.0' >=20 > I know that sqlite stores everything as strings, but it should be convert= ed to float in Python, and I don't know where to do this. The problem is (s= uppose account has a name): > >>> accounts[0].setName('sales') > >>> ec.saveChanges() > .... > Modeling.Validation.ValidationException: Validation for key saldo failed: > - Wrong type > Validation for key OBJECT_WIDE_VALIDATION failed: > - Validation of object <Conta.Cuenta.Cuenta instance at 0x00DC4FE8> as a = whole failed >=20 > because although it has been initialised with 0.0 now it is '0.0' (type s= tring). >=20 > Thanx in advance, > Erny |