summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-01-20 12:10:40 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2016-01-20 12:10:40 -0500
commit165fa15b0f9dbca50539aa7da377c5da5ac0fc79 (patch)
treee9818473d8d0757f067feb4f215e8f9f4fd4b91c /lib/sqlalchemy/ext/compiler.py
parenta2badb751f09299c925bd96a9fd2e76acca04269 (diff)
downloadsqlalchemy-165fa15b0f9dbca50539aa7da377c5da5ac0fc79.tar.gz
- add a note that the literal_binds flag should be used
when cross-compiling from DDL to SQL, fixes #3615
Diffstat (limited to 'lib/sqlalchemy/ext/compiler.py')
-rw-r--r--lib/sqlalchemy/ext/compiler.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/sqlalchemy/ext/compiler.py b/lib/sqlalchemy/ext/compiler.py
index 9717e41c0..d4d2ed2ef 100644
--- a/lib/sqlalchemy/ext/compiler.py
+++ b/lib/sqlalchemy/ext/compiler.py
@@ -121,9 +121,19 @@ below where we generate a CHECK constraint that embeds a SQL expression::
def compile_my_constraint(constraint, ddlcompiler, **kw):
return "CONSTRAINT %s CHECK (%s)" % (
constraint.name,
- ddlcompiler.sql_compiler.process(constraint.expression)
+ ddlcompiler.sql_compiler.process(
+ constraint.expression, literal_binds=True)
)
+Above, we add an additional flag to the process step as called by
+:meth:`.SQLCompiler.process`, which is the ``literal_binds`` flag. This
+indicates that any SQL expression which refers to a :class:`.BindParameter`
+object or other "literal" object such as those which refer to strings or
+integers should be rendered **in-place**, rather than being referred to as
+a bound parameter; when emitting DDL, bound parameters are typically not
+supported.
+
+
.. _enabling_compiled_autocommit:
Enabling Autocommit on a Construct