summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/databases/informix.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-08-14 21:53:32 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-08-14 21:53:32 +0000
commit087f235c33c1be4e0778231e8344a50dc4005c59 (patch)
treed47c35d1e520e43c05ec869304870c0b6c87f736 /lib/sqlalchemy/databases/informix.py
parente58063aa91d893d76e9f34fbc3ea21818185844d (diff)
downloadsqlalchemy-087f235c33c1be4e0778231e8344a50dc4005c59.tar.gz
- merged "fasttypes" branch. this branch changes the signature
of convert_bind_param() and convert_result_value() to callable-returning bind_processor() and result_processor() methods. if no callable is returned, no pre/post processing function is called. - hooks added throughout base/sql/defaults to optimize the calling of bind param/result processors so that method call overhead is minimized. special cases added for executemany() scenarios such that unneeded "last row id" logic doesn't kick in, parameters aren't excessively traversed. - new performance tests show a combined mass-insert/mass-select test as having 68% fewer function calls than the same test run against 0.3. - general performance improvement of result set iteration is around 10-20%.
Diffstat (limited to 'lib/sqlalchemy/databases/informix.py')
-rw-r--r--lib/sqlalchemy/databases/informix.py85
1 files changed, 50 insertions, 35 deletions
diff --git a/lib/sqlalchemy/databases/informix.py b/lib/sqlalchemy/databases/informix.py
index a3ef99916..21ecf1538 100644
--- a/lib/sqlalchemy/databases/informix.py
+++ b/lib/sqlalchemy/databases/informix.py
@@ -61,27 +61,33 @@ class InfoDateTime(sqltypes.DateTime ):
def get_col_spec(self):
return "DATETIME YEAR TO SECOND"
- def convert_bind_param(self, value, dialect):
- if value is not None:
- if value.microsecond:
- value = value.replace( microsecond = 0 )
- return value
-
+ def bind_processor(self, dialect):
+ def process(value):
+ if value is not None:
+ if value.microsecond:
+ value = value.replace( microsecond = 0 )
+ return value
+ return process
+
class InfoTime(sqltypes.Time ):
def get_col_spec(self):
return "DATETIME HOUR TO SECOND"
- def convert_bind_param(self, value, dialect):
- if value is not None:
- if value.microsecond:
- value = value.replace( microsecond = 0 )
- return value
+ def bind_processor(self, dialect):
+ def process(value):
+ if value is not None:
+ if value.microsecond:
+ value = value.replace( microsecond = 0 )
+ return value
+ return process
- def convert_result_value(self, value, dialect):
- if isinstance( value , datetime.datetime ):
- return value.time()
- else:
- return value
+ def result_processor(self, dialect):
+ def process(value):
+ if isinstance( value , datetime.datetime ):
+ return value.time()
+ else:
+ return value
+ return process
class InfoText(sqltypes.String):
def get_col_spec(self):
@@ -91,36 +97,45 @@ class InfoString(sqltypes.String):
def get_col_spec(self):
return "VARCHAR(%(length)s)" % {'length' : self.length}
- def convert_bind_param( self , value , dialect ):
- if value == '':
- return None
- else:
- return value
-
+ def bind_processor(self, dialect):
+ def process(value):
+ if value == '':
+ return None
+ else:
+ return value
+ return process
+
class InfoChar(sqltypes.CHAR):
def get_col_spec(self):
return "CHAR(%(length)s)" % {'length' : self.length}
+
class InfoBinary(sqltypes.Binary):
def get_col_spec(self):
return "BYTE"
+
class InfoBoolean(sqltypes.Boolean):
default_type = 'NUM'
def get_col_spec(self):
return "SMALLINT"
- def convert_result_value(self, value, dialect):
- if value is None:
- return None
- return value and True or False
- def convert_bind_param(self, value, dialect):
- if value is True:
- return 1
- elif value is False:
- return 0
- elif value is None:
- return None
- else:
+
+ def result_processor(self, dialect):
+ def process(value):
+ if value is None:
+ return None
return value and True or False
-
+ return process
+
+ def bind_processor(self, dialect):
+ def process(value):
+ if value is True:
+ return 1
+ elif value is False:
+ return 0
+ elif value is None:
+ return None
+ else:
+ return value and True or False
+ return process
colspecs = {
sqltypes.Integer : InfoInteger,