summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/compiler.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r--lib/sqlalchemy/sql/compiler.py19
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index d906bf5d4..1ab0ba405 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -579,8 +579,9 @@ class SQLCompiler(engine.Compiled):
else:
return fn(" " + operator + " ")
- def visit_bindparam(self, bindparam, within_columns_clause=False,
+ def visit_bindparam(self, bindparam, within_columns_clause=False,
literal_binds=False, **kwargs):
+
if literal_binds or \
(within_columns_clause and \
self.ansi_bind_rules):
@@ -591,6 +592,7 @@ class SQLCompiler(engine.Compiled):
within_columns_clause=True, **kwargs)
name = self._truncate_bindparam(bindparam)
+
if name in self.binds:
existing = self.binds[name]
if existing is not bindparam:
@@ -600,7 +602,8 @@ class SQLCompiler(engine.Compiled):
"unique bind parameter of the same name" %
bindparam.key
)
- elif getattr(existing, '_is_crud', False):
+ elif getattr(existing, '_is_crud', False) or \
+ getattr(bindparam, '_is_crud', False):
raise exc.CompileError(
"bindparam() name '%s' is reserved "
"for automatic usage in the VALUES or SET "
@@ -992,18 +995,8 @@ class SQLCompiler(engine.Compiled):
bindparam = sql.bindparam(col.key, value,
type_=col.type, required=required)
bindparam._is_crud = True
- if col.key in self.binds:
- raise exc.CompileError(
- "bindparam() name '%s' is reserved "
- "for automatic usage in the VALUES or SET clause of this "
- "insert/update statement. Please use a "
- "name other than column name when using bindparam() "
- "with insert() or update() (for example, 'b_%s')."
- % (col.key, col.key)
- )
+ return bindparam._compiler_dispatch(self)
- self.binds[col.key] = bindparam
- return self.bindparam_string(self._truncate_bindparam(bindparam))
def _get_colparams(self, stmt):
"""create a set of tuples representing column/string pairs for use