summaryrefslogtreecommitdiff
path: root/tests/test_postgresql.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2018-01-22 14:40:23 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2018-01-22 15:08:57 -0500
commit70dfb13759d782d84aff94ae3a4ccb8f5d4fd4db (patch)
tree1f1887dc5b159418a03c01c261f1624fc5a79444 /tests/test_postgresql.py
parentf5af1c0823199d0aca152c9885ace36c5829a36a (diff)
downloadalembic-70dfb13759d782d84aff94ae3a4ccb8f5d4fd4db.tar.gz
Render ExcludeContraint Column as column, not plain string
Fixed bug where autogenerate of :class:`.ExcludeConstraint` would render a raw quoted name for a Column that has case-sensitive characters, which when invoked as an inline member of the Table would produce a stack trace that the quoted name is not found. An incoming Column object is now rendered as ``sa.column('name')``. Change-Id: Ic84fc0b0fbaa5816ece1944043cd01a653bfe4ce Fixes: #478
Diffstat (limited to 'tests/test_postgresql.py')
-rw-r--r--tests/test_postgresql.py59
1 files changed, 58 insertions, 1 deletions
diff --git a/tests/test_postgresql.py b/tests/test_postgresql.py
index e60a02d..ae74c08 100644
--- a/tests/test_postgresql.py
+++ b/tests/test_postgresql.py
@@ -760,11 +760,37 @@ unique=False, """
eq_ignore_whitespace(
autogenerate.render_op_text(autogen_context, op_obj),
- "op.create_exclude_constraint('t_excl_x', 't', ('x', '>'), "
+ "op.create_exclude_constraint('t_excl_x', 't', (sa.column('x'), '>'), "
"where=sa.text(!U'x != 2'), using='gist')"
)
@config.requirements.fail_before_sqla_100
+ def test_add_exclude_constraint_case_sensitive(self):
+ from sqlalchemy.dialects.postgresql import ExcludeConstraint
+
+ autogen_context = self.autogen_context
+
+ m = MetaData()
+ t = Table('TTAble', m,
+ Column('XColumn', String),
+ Column('YColumn', String)
+ )
+
+ op_obj = ops.AddConstraintOp.from_constraint(ExcludeConstraint(
+ (t.c.XColumn, ">"),
+ where=t.c.XColumn != 2,
+ using="gist",
+ name="t_excl_x"
+ ))
+
+ eq_ignore_whitespace(
+ autogenerate.render_op_text(autogen_context, op_obj),
+ "op.create_exclude_constraint('t_excl_x', 'TTAble', (sa.column('XColumn'), '>'), "
+ "where=sa.text(!U'\"XColumn\" != 2'), using='gist')"
+ )
+
+
+ @config.requirements.fail_before_sqla_100
def test_inline_exclude_constraint(self):
from sqlalchemy.dialects.postgresql import ExcludeConstraint
@@ -794,6 +820,37 @@ unique=False, """
")"
)
+ @config.requirements.fail_before_sqla_100
+ def test_inline_exclude_constraint_case_sensitive(self):
+ from sqlalchemy.dialects.postgresql import ExcludeConstraint
+
+ autogen_context = self.autogen_context
+
+ m = MetaData()
+ t = Table(
+ 'TTable', m,
+ Column('XColumn', String),
+ Column('YColumn', String),
+ )
+ ExcludeConstraint(
+ (t.c.XColumn, ">"),
+ using="gist",
+ where='"XColumn" != 2',
+ name="TExclX"
+ )
+
+ op_obj = ops.CreateTableOp.from_table(t)
+
+ eq_ignore_whitespace(
+ autogenerate.render_op_text(autogen_context, op_obj),
+ "op.create_table('TTable',sa.Column('XColumn', sa.String(), "
+ "nullable=True),"
+ "sa.Column('YColumn', sa.String(), nullable=True),"
+ "postgresql.ExcludeConstraint((sa.column('XColumn'), '>'), "
+ "where=sa.text(!U'\"XColumn\" != 2'), using='gist', "
+ "name='TExclX'))"
+ )
+
@config.requirements.sqlalchemy_09
def test_json_type(self):
if config.requirements.sqlalchemy_110.enabled: