summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2017-04-04 10:02:39 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2017-04-04 10:02:39 -0400
commit4a4b17e0d3a154094858e73ed1e32c5733047de8 (patch)
treeecf33d818d171e321e3374c54d965628df2fb2ac /lib/sqlalchemy/sql/compiler.py
parent9609f5ffb52ce8a4969059e299773ac7176dbb0d (diff)
downloadsqlalchemy-4a4b17e0d3a154094858e73ed1e32c5733047de8.tar.gz
Apply SQL compilation to sqltext for column-level CHECK constraint
Fixed bug where a column-level :class:`.CheckConstraint` would fail to compile the SQL expression using the underlying dialect compiler as well as apply proper flags to generate literal values as inline, in the case that the sqltext is a Core expression and not just a plain string. This was long-ago fixed for table-level check constraints in 0.9 as part of :ticket:`2742`, which more commonly feature Core SQL expressions as opposed to plain string expressions. Change-Id: I1301ba4b40063e91bc47726aecc5f4990ffcaeda Fixes: #3957
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r--lib/sqlalchemy/sql/compiler.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index 441502898..b18f90312 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -2602,7 +2602,9 @@ class DDLCompiler(Compiled):
formatted_name = self.preparer.format_constraint(constraint)
if formatted_name is not None:
text += "CONSTRAINT %s " % formatted_name
- text += "CHECK (%s)" % constraint.sqltext
+ text += "CHECK (%s)" % self.sql_compiler.process(constraint.sqltext,
+ include_table=False,
+ literal_binds=True)
text += self.define_constraint_deferrability(constraint)
return text