]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- add a note that the literal_binds flag should be used
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 20 Jan 2016 17:10:40 +0000 (12:10 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 20 Jan 2016 17:10:40 +0000 (12:10 -0500)
when cross-compiling from DDL to SQL, fixes #3615

lib/sqlalchemy/ext/compiler.py

index 9717e41c01285e047a6397147311e7763e503854..d4d2ed2efac42cc923f21a8601506a108d81d68e 100644 (file)
@@ -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