dabo Commit
Revision 3680
Date: 2007-11-14 09:25:18 -0800 (Wed, 14 Nov 2007)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/3680
Changed:
U trunk/dabo/db/__init__.py
U trunk/dabo/db/dCursorMixin.py
Log:
Changed the way Dabo determines field types in queries. Previously, all fields
that were not in the underlying table (e.g., from joins) were left in their
'natural' python state, whereas the same fields when in the underlying table
were 'massaged' by Dabo. The main example of this is the treatment of
float/Decimal, as pointed out by Dave Nation on dabo-users.
Diff:
Modified: trunk/dabo/db/__init__.py
===================================================================
--- trunk/dabo/db/__init__.py 2007-11-14 17:12:01 UTC (rev 3679)
+++ trunk/dabo/db/__init__.py 2007-11-14 17:25:18 UTC (rev 3680)
@@ -63,3 +63,13 @@
def getDaboType(pythonType):
"""Given a python data type, return the associated Dabo type code."""
return pythonTypes.get(pythonType, "?")
+
+def getDataType(pythonType):
+ """Given a python data type, returns the appropriate type for database
values.
+ This is generally the same as the original, except when the value is
float and
+ the Decimal type is available.
+ """
+ ret = pythonType
+ if pythonType is float:
+ ret = daboTypes["N"]
+ return ret
Modified: trunk/dabo/db/dCursorMixin.py
===================================================================
--- trunk/dabo/db/dCursorMixin.py 2007-11-14 17:12:01 UTC (rev 3679)
+++ trunk/dabo/db/dCursorMixin.py 2007-11-14 17:25:18 UTC (rev 3680)
@@ -190,6 +190,8 @@
showError = False
if _newQuery:
pythonType = self._types.get(field_name,
type(field_val))
+ if pythonType is None:
+ pythonType = self._types[field_name] =
dabo.db.getDataType(type(field_val))
daboType = dabo.db.getDaboType(pythonType)
if pythonType is None or isinstance(field_val,
pythonType):
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/dabo-dev/[EMAIL PROTECTED]