[Modeling-users] Re: MySQL double
Status: Abandoned
Brought to you by:
sbigaret
|
From: Sebastien B. <sbi...@us...> - 2004-02-03 13:38:22
|
Hi,=20
Ralf Sigmund <ral...@ip...> wrote:
> Greetings!
>=20
> I have recently started to use modeling for my bioinformatics work.
> I like it a lot but now i ran into a small problem.
> I often need to store small numbers like 1.24e-127
> The MySQL datataype double stores theese correctly while float reduces th=
em to
> 0.0 which is a catastrophe for me.
> So I tried to specify double as external datatayp, but the mdl-validate f=
ails
> telling me that double is not supported.
> Is it possible to expand the mysql adapter to support double?
Absolutely :) Apply the attached patch and you should be able to use
MySQL's DOUBLE. Use precision=3D0, scale=3D0 for the default DOUBLE, or
precision=3DM, scale=3DD for DOUBLE(M,D). If you can report that this
works as expected, this will be in the next release.
Hope this helps,
-- S=E9bastien.
Index: DatabaseAdaptors/MySQLAdaptorLayer/MySQLSQLExpression.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/MySQL=
AdaptorLayer/MySQLSQLExpression.py,v
retrieving revision 1.8
diff -u -r1.8 MySQLSQLExpression.py
--- DatabaseAdaptors/MySQLAdaptorLayer/MySQLSQLExpression.py 15 Dec 2003=
15:05:00 -0000 1.8
+++ DatabaseAdaptors/MySQLAdaptorLayer/MySQLSQLExpression.py 3 Feb 2004 =
13:31:02 -0000
@@ -34,7 +34,8 @@
__version__=3D'$Revision: 1.8 $'[11:-2]
=20
from Modeling.DatabaseAdaptors.MySQLAdaptorLayer.mysql_utils import *
-from Modeling.SQLExpression import SQLExpression, DateType, CharacterType
+from Modeling.SQLExpression import SQLExpression
+from Modeling.SQLExpression import DateType, CharacterType, NumericType
from Modeling.logging import trace, db_trace
import string
=20
@@ -117,7 +118,8 @@
values=3DSQLExpression.valueTypeForExternalTypeMapping.im_func(self)
del values['timestamp']
values.update({ 'datetime': DateType,
- 'text': CharacterType })
+ 'text': CharacterType,
+ 'double': NumericType })
return values
=20
def prepareSelectCountExpressionWithAttributes(self,
|