summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ansisql.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-03-19 04:20:06 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-03-19 04:20:06 +0000
commit5c1e9392a92e464c63d7f7a625a180ce4a5037c3 (patch)
tree007d26cf1ae9905802aa9c56589cfeb7880e6c84 /lib/sqlalchemy/ansisql.py
parentd9f76884fea7a7ca87f494d1a3a0b17377ce3b6b (diff)
downloadsqlalchemy-5c1e9392a92e464c63d7f7a625a180ce4a5037c3.tar.gz
got clause elements inside INSERTs going...
Diffstat (limited to 'lib/sqlalchemy/ansisql.py')
-rw-r--r--lib/sqlalchemy/ansisql.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/sqlalchemy/ansisql.py b/lib/sqlalchemy/ansisql.py
index c0aebcbae..322af1562 100644
--- a/lib/sqlalchemy/ansisql.py
+++ b/lib/sqlalchemy/ansisql.py
@@ -452,13 +452,21 @@ class ANSICompiler(sql.Compiled):
self.isinsert = True
colparams = self._get_colparams(insert_stmt)
- for c in colparams:
- b = c[1]
- self.binds[b.key] = b
- self.binds[b.shortname] = b
-
+
+ def create_param(p):
+ if isinstance(p, sql.BindParamClause):
+ self.binds[p.key] = p
+ self.binds[p.shortname] = p
+ return self.bindparam_string(p.key)
+ else:
+ p.accept_visitor(self)
+ if isinstance(p, sql.ClauseElement) and not isinstance(p, sql.ColumnElement):
+ return "(" + self.get_str(p) + ")"
+ else:
+ return self.get_str(p)
+
text = ("INSERT INTO " + insert_stmt.table.fullname + " (" + string.join([c[0].name for c in colparams], ', ') + ")" +
- " VALUES (" + string.join([self.bindparam_string(c[1].key) for c in colparams], ', ') + ")")
+ " VALUES (" + string.join([create_param(c[1]) for c in colparams], ', ') + ")")
self.strings[insert_stmt] = text
@@ -482,7 +490,7 @@ class ANSICompiler(sql.Compiled):
return self.bindparam_string(p.key)
else:
p.accept_visitor(self)
- if isinstance(p, sql.ClauseElement) and not isinstance(p, sql.ColumnClause):
+ if isinstance(p, sql.ClauseElement) and not isinstance(p, sql.ColumnElement):
return "(" + self.get_str(p) + ")"
else:
return self.get_str(p)