diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-04-04 10:02:39 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-04-04 10:02:39 -0400 |
commit | 4a4b17e0d3a154094858e73ed1e32c5733047de8 (patch) | |
tree | ecf33d818d171e321e3374c54d965628df2fb2ac /test/sql/test_constraints.py | |
parent | 9609f5ffb52ce8a4969059e299773ac7176dbb0d (diff) | |
download | sqlalchemy-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 'test/sql/test_constraints.py')
-rw-r--r-- | test/sql/test_constraints.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/sql/test_constraints.py b/test/sql/test_constraints.py index aebbb4c30..3365b3cf0 100644 --- a/test/sql/test_constraints.py +++ b/test/sql/test_constraints.py @@ -1137,6 +1137,19 @@ class ConstraintCompilationTest(fixtures.TestBase, AssertsCompiledSQL): "ALTER TABLE tbl ADD CHECK (a > 5)" ) + def test_render_check_constraint_inline_sql_literal(self): + t, t2 = self._constraint_create_fixture() + + m = MetaData() + t = Table( + 't', m, + Column('a', Integer, CheckConstraint(Column('a', Integer) > 5))) + + self.assert_compile( + schema.CreateColumn(t.c.a), + "a INTEGER CHECK (a > 5)" + ) + def test_render_index_sql_literal(self): t, t2 = self._constraint_create_fixture() |