summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Yves David <pierre-yves.david@logilab.fr>2008-08-04 14:44:24 +0200
committerPierre-Yves David <pierre-yves.david@logilab.fr>2008-08-04 14:44:24 +0200
commit1ea16bb5f8ad86619a2fbf29ae05c78d943e68e6 (patch)
tree4800a85d12d31b4c98219aa5e5bb557daec8b5df
parenta514ba5f86b31372222202c271919f468cec523a (diff)
downloadlogilab-common-1ea16bb5f8ad86619a2fbf29ae05c78d943e68e6.tar.gz
add Decimal Type support for database apy
-rw-r--r--ChangeLog96
-rw-r--r--adbh.py1
-rw-r--r--db.py15
-rw-r--r--test/unittest_db.py2
4 files changed, 66 insertions, 48 deletions
diff --git a/ChangeLog b/ChangeLog
index c806048..e2bf725 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,10 @@ ChangeLog for logilab.common
* add a with_tempdir decorator ensuring all temporary files and dirs are removed
+ * improve DotBackend configuration. graphiz rendered can now be selected and additionnal graph parameter used
+
+ * db: support of Decimal Type
+
2008-06-25 -- 0.33.0
@@ -164,12 +168,12 @@ ChangeLog for logilab.common
2007-10-17 -- 0.23.0
* db:
-
- - mark support_users and support_groups methods as obsolete in
+
+ - mark support_users and support_groups methods as obsolete in
favor of users_support and groups_support attributes
- - new ilike_support property on dbms helpers
- - extended db helper api
- - completed mysql support
+ - new ilike_support property on dbms helpers
+ - extended db helper api
+ - completed mysql support
* textutils: new unormalize function to normalize diacritical chars by
their ascii equivalent
@@ -242,9 +246,9 @@ ChangeLog for logilab.common
2006-11-14 -- 0.21.0
* db:
-
- - new optional keepownership argument to backup|restore_database methods
- - only register mxDatetime converters on psycopg2 adapter if
+
+ - new optional keepownership argument to backup|restore_database methods
+ - only register mxDatetime converters on psycopg2 adapter if
mx.DateTime is available
* moved some stuff which was in common __init__ file into specific
@@ -341,11 +345,11 @@ ChangeLog for logilab.common
2006-09-22 -- 0.19.1
* db:
-
- - fixed bug when querying boolean on sqlite using python's bool type
- - fixed time handling and added an adapter for DateTimeDeltaType
- - added "drop_on_commit" argument to create_temporary_table on db helper
- - added missing implementation of executemany on pysqlite2 wrapper to
+
+ - fixed bug when querying boolean on sqlite using python's bool type
+ - fixed time handling and added an adapter for DateTimeDeltaType
+ - added "drop_on_commit" argument to create_temporary_table on db helper
+ - added missing implementation of executemany on pysqlite2 wrapper to
support pyargs correctly like execute
* optik_ext: fixed "named" type option to support csv values and to return
@@ -401,10 +405,10 @@ ChangeLog for logilab.common
2006-05-19 -- 0.16.0
* testlib:
-
- - added a set of command line options (PYDEBUG is deprecated,
+
+ - added a set of command line options (PYDEBUG is deprecated,
use the -i/--pdb option, and added -x/--exitfirst option)
- - added support for generative tests
+ - added support for generative tests
* db:
- fix get_connection parameter order and host/port handling
@@ -459,9 +463,9 @@ ChangeLog for logilab.common
* testlib: ability to skip a test
* configuration:
-
- - cleaner configuration file generation
- - refactoring so that we can have more control on file
+
+ - cleaner configuration file generation
+ - refactoring so that we can have more control on file
configuration loading using read_config_file and load_config_file
instead of load_file_configuration
@@ -536,15 +540,15 @@ ChangeLog for logilab.common
2005-02-16 -- 0.9.2
* textutils:
-
- - added epydoc documentation
- - new sep argument to the get_csv function
- - fix pb with normalize_* functions on windows platforms
+
+ - added epydoc documentation
+ - new sep argument to the get_csv function
+ - fix pb with normalize_* functions on windows platforms
* fileutils:
-
- - added epydoc documentation
- - fixed bug in get_by_ext (renamed files_by_ext) with the
+
+ - added epydoc documentation
+ - fixed bug in get_by_ext (renamed files_by_ext) with the
exclude_dirs argument
* configuration:
@@ -563,10 +567,10 @@ ChangeLog for logilab.common
2005-02-04 -- 0.9.1
* astng:
-
- - remove buggy print
- - fixed builder to deal with builtin methods
- - fixed raw_building.build_function with python 2.4
+
+ - remove buggy print
+ - fixed builder to deal with builtin methods
+ - fixed raw_building.build_function with python 2.4
* modutils: code cleanup, some reimplementation based on "imp",
better handling of windows specific extensions, epydoc documentation
@@ -581,25 +585,25 @@ ChangeLog for logilab.common
2005-01-20 -- 0.9.0
* astng:
-
- - refactoring of some huge methods
- - fix interface resolving when __implements__ is defined in a parent
+
+ - refactoring of some huge methods
+ - fix interface resolving when __implements__ is defined in a parent
class in another module
- - add special code in the builder to fix problem with qt
- - new source_line method on Node
- - fix sys.path during parsing to avoid some failure when trying
+ - add special code in the builder to fix problem with qt
+ - new source_line method on Node
+ - fix sys.path during parsing to avoid some failure when trying
to get imported names by `from module import *`, and use an astng
building instead of exec'ing the statement
- - fix possible AttributeError with Function.type
- - manager.astng_from_file fallback to astng_from_module if possible
+ - fix possible AttributeError with Function.type
+ - manager.astng_from_file fallback to astng_from_module if possible
* textutils: fix bug in normalize_paragraph, unquote handle empty string
correctly
* modutils:
-
- - use a cache in has_module to speed up things when heavily used
- - fix file_from_modpath to handle pyxml and os.path
+
+ - use a cache in has_module to speed up things when heavily used
+ - fix file_from_modpath to handle pyxml and os.path
* configuration: fix problem with serialization/deserialization of empty
string
@@ -625,12 +629,12 @@ ChangeLog for logilab.common
2004-11-03 -- 0.7.1
* astng:
-
- - don't raise a syntax error on files missing a trailing \n.
- - fix utils.is_abstract (was causing an unexpected exception if a
+
+ - don't raise a syntax error on files missing a trailing \n.
+ - fix utils.is_abstract (was causing an unexpected exception if a
string exception was raised).
- - fix utils.get_implemented.
- - fix file based manager's cache problem.
+ - fix utils.get_implemented.
+ - fix file based manager's cache problem.
* textutils: fixed normalize_text / normalize_paragraph functions
diff --git a/adbh.py b/adbh.py
index 880eb8b..46a0909 100644
--- a/adbh.py
+++ b/adbh.py
@@ -130,6 +130,7 @@ class _GenericAdvFuncHelper:
'String' : 'text',
'Int' : 'integer',
'Float' : 'float',
+ 'Decimal' : 'decimal',
'Boolean' : 'boolean',
'Date' : 'date',
'Time' : 'time',
diff --git a/db.py b/db.py
index 25e6df4..06c565a 100644
--- a/db.py
+++ b/db.py
@@ -348,6 +348,17 @@ class _PySqlite2Adapter(DBAPIAdapter):
def adapt_boolean(bval):
return str(bval).upper()
sqlite.register_adapter(bool, adapt_boolean)
+
+
+ # decimal type handling
+ from decimal import Decimal
+ def adapt_decimal(data):
+ return u"%s" % data
+ sqlite.register_adapter(Decimal,adapt_decimal)
+
+ def convert_decimal(data):
+ return Decimal(data)
+ sqlite.register_converter('decimal',convert_decimal)
# date/time types handling
if HAS_MX_DATETIME:
@@ -392,7 +403,9 @@ class _PySqlite2Adapter(DBAPIAdapter):
if kwargs is None:
self.__class__.__bases__[0].execute(self, sql)
else:
- self.__class__.__bases__[0].execute(self, self._replace_parameters(sql, kwargs), kwargs)
+ final_sql = self._replace_parameters(sql, kwargs)
+ self.__class__.__bases__[0].execute(self, final_sql , kwargs)
+
def executemany(self, sql, kwargss):
if not isinstance(kwargss, (list, tuple)):
kwargss = tuple(kwargss)
diff --git a/test/unittest_db.py b/test/unittest_db.py
index 9d10aba..ce05c8c 100644
--- a/test/unittest_db.py
+++ b/test/unittest_db.py
@@ -162,7 +162,7 @@ class DBAPIAdaptersTC(TestCase):
self.skip('postgresql pgdb module not installed')
number_types = ('int2', 'int4', 'serial',
'int8', 'float4', 'float8',
- 'numeric', 'bool', 'money')
+ 'numeric', 'bool', 'money', 'decimal')
for num_type in number_types:
yield self.assertEquals, num_type, module.NUMBER
yield self.assertNotEquals, 'char', module.NUMBER