summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/sql.py')
-rw-r--r--lib/sqlalchemy/sql.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py
index 18591c24c..2aa1342ca 100644
--- a/lib/sqlalchemy/sql.py
+++ b/lib/sqlalchemy/sql.py
@@ -273,12 +273,19 @@ class AbstractDialect(object):
"""represents the behavior of a particular database. Used by Compiled objects."""
pass
-class ClauseParameters(util.OrderedDict):
- """represents a dictionary/iterator of bind parameter key names/values. Includes parameters compiled with a Compiled object as well as additional arguments passed to the Compiled object's get_params() method. Parameter values will be converted as per the TypeEngine objects present in the bind parameter objects. The non-converted value can be retrieved via the get_original method. For Compiled objects that compile positional parameters, the values() iteration of the object will return the parameter values in the correct order."""
- def __init__(self, dialect):
+class ClauseParameters(dict):
+ """represents a dictionary/iterator of bind parameter key names/values.
+
+ Tracks the original BindParam objects as well as the keys/position of each
+ parameter, and can return parameters as a dictionary or a list.
+ Will process parameter values according to the TypeEngine objects present in
+ the BindParams.
+ """
+ def __init__(self, dialect, positional=None):
super(ClauseParameters, self).__init__(self)
self.dialect=dialect
self.binds = {}
+ self.positional = positional or []
def set_parameter(self, key, value, bindparam):
self[key] = value
self.binds[key] = bindparam
@@ -290,10 +297,10 @@ class ClauseParameters(util.OrderedDict):
if self.binds.has_key(key):
v = self.binds[key].typeprocess(v, self.dialect)
return v
- def values(self):
- return [self[key] for key in self]
def get_original_dict(self):
return self.copy()
+ def get_raw_list(self):
+ return [self[key] for key in self.positional]
def get_raw_dict(self):
d = {}
for k in self: