diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2005-08-28 19:36:41 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2005-08-28 19:36:41 +0000 |
commit | 3d276a682e034abfca68567d1533e20d797efa6b (patch) | |
tree | b614484a1f247e27136d665d6552dfad45ab59b6 /lib/sqlalchemy/ansisql.py | |
parent | f91cfdb8ac8794ea8e9f348b21ebbbf553d8bd4b (diff) | |
download | sqlalchemy-3d276a682e034abfca68567d1533e20d797efa6b.tar.gz |
Diffstat (limited to 'lib/sqlalchemy/ansisql.py')
-rw-r--r-- | lib/sqlalchemy/ansisql.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/sqlalchemy/ansisql.py b/lib/sqlalchemy/ansisql.py index e0dcc58bd..1782a29f0 100644 --- a/lib/sqlalchemy/ansisql.py +++ b/lib/sqlalchemy/ansisql.py @@ -68,12 +68,17 @@ class ANSICompiler(sql.Compiled): def get_whereclause(self, obj): return self.wheres.get(obj, None) - + def get_params(self, **params): """returns the bind params for this compiled object, with values overridden by those given in the **params dictionary""" d = {} - for key, value in params.iteritems(): + if self.bindparams is not None: + bindparams = self.bindparams.copy() + else: + bindparams = {} + bindparams.update(params) + for key, value in bindparams.iteritems(): try: b = self.binds[key] except KeyError: @@ -84,7 +89,7 @@ class ANSICompiler(sql.Compiled): d.setdefault(b.key, b.value) return d - + def visit_column(self, column): if column.table.name is None: self.strings[column] = column.name @@ -121,19 +126,18 @@ class ANSICompiler(sql.Compiled): result += " " + self.get_str(binary.right) if binary.parens: result = "(" + result + ")" - self.strings[binary] = result - + def visit_bindparam(self, bindparam): self.binds[bindparam.shortname] = bindparam - count = 1 key = bindparam.key - + + # redefine the generated name of the bind param in the case + # that we have multiple conflicting bind parameters. while self.binds.setdefault(key, bindparam) is not bindparam: key = "%s_%d" % (bindparam.key, count) count += 1 - self.strings[bindparam] = ":" + key def visit_alias(self, alias): |