diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-03-13 00:24:54 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-03-13 00:24:54 +0000 |
commit | c5e1abc7f7adce841775ea92b72bcf95207027af (patch) | |
tree | b406fd4e6ede57ed8805a40a909c3c69207d3414 /lib/sqlalchemy/sql.py | |
parent | 2ce45d70c7e499fd6c239d963f50cd839b28629b (diff) | |
download | sqlalchemy-c5e1abc7f7adce841775ea92b72bcf95207027af.tar.gz |
refactor to Compiled.get_params() to return new ClauseParameters object, a more intelligent bind parameter dictionary that does type conversions late and preserves the unconverted value; used to fix mappers not comparing correct value in post-fetch [ticket:110]
removed pre_exec assertion from oracle/firebird regarding "check for sequence/primary key value"
fix to Unicode type to check for null, fixes [ticket:109]
create_engine() now uses genericized parameters; host/hostname, db/dbname/database, password/passwd, etc. for all engine connections
fix to select([func(column)]) so that it creates a FROM clause to the column's table, fixes [ticket:111]
doc updates for column defaults, indexes, connection pooling, engine params
unit tests for the above bugfixes
Diffstat (limited to 'lib/sqlalchemy/sql.py')
-rw-r--r-- | lib/sqlalchemy/sql.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py index 89b4b5585..4eaf33e00 100644 --- a/lib/sqlalchemy/sql.py +++ b/lib/sqlalchemy/sql.py @@ -232,6 +232,27 @@ def _is_literal(element): def is_column(col): return isinstance(col, ColumnElement) +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, engine=None): + super(ClauseParameters, self).__init__(self) + self.engine = engine + self.binds = {} + def set_parameter(self, key, value, bindparam): + self[key] = value + self.binds[key] = bindparam + def get_original(self, key): + return super(ClauseParameters, self).__getitem__(key) + def __getitem__(self, key): + v = super(ClauseParameters, self).__getitem__(key) + if self.engine is not None and self.binds.has_key(key): + v = self.binds[key].typeprocess(v, self.engine) + return v + def values(self): + return [self[key] for key in self] + def get_original_dict(self): + return self.copy() + class ClauseVisitor(object): """Defines the visiting of ClauseElements.""" def visit_column(self, column):pass @@ -779,6 +800,8 @@ class Function(ClauseList, ColumnElement): clause = BindParamClause(self.name, clause, shortname=self.name, type=None) self.clauses.append(clause) def _process_from_dict(self, data, asfrom): + super(Function, self)._process_from_dict(data, asfrom) + # this helps a Select object get the engine from us data.setdefault(self, self) def copy_container(self): clauses = [clause.copy_container() for clause in self.clauses] |