diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-04-24 16:19:08 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-04-24 16:22:29 -0400 |
commit | 029d0f75385298f8056c04eba1d2f9563126a8a6 (patch) | |
tree | 433ac6eae152ab99373a55bf6fcaf023563d3cd4 /test/dialect/postgresql/test_compiler.py | |
parent | 6560bf82f387ca53c79f91f93ae97e6594795da8 (diff) | |
download | sqlalchemy-029d0f75385298f8056c04eba1d2f9563126a8a6.tar.gz |
test / document postgresql_ops against a labeled expression
Since postgresql_ops explicitly states that it expects
string keys, to apply to a function call or expression one
needs to give the SQL expression a label that can be referred
to by name in the dictionary. test / document this.
Change-Id: I4bc4ade46dac27f9c1b92e7823433292beab97b9
Fixes: #3970
Diffstat (limited to 'test/dialect/postgresql/test_compiler.py')
-rw-r--r-- | test/dialect/postgresql/test_compiler.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py index eddf20877..0533016cd 100644 --- a/test/dialect/postgresql/test_compiler.py +++ b/test/dialect/postgresql/test_compiler.py @@ -316,6 +316,32 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): '(data text_pattern_ops, data2 int4_ops)', dialect=postgresql.dialect()) + def test_create_index_with_labeled_ops(self): + m = MetaData() + tbl = Table('testtbl', m, + Column('data', String), + Column('data2', Integer, key='d2')) + + idx = Index('test_idx1', func.lower(tbl.c.data).label('data_lower'), + postgresql_ops={'data_lower': 'text_pattern_ops'}) + + idx2 = Index( + 'test_idx2', + (func.xyz(tbl.c.data) + tbl.c.d2).label('bar'), + tbl.c.d2.label('foo'), + postgresql_ops={'bar': 'text_pattern_ops', + 'foo': 'int4_ops'}) + + self.assert_compile(schema.CreateIndex(idx), + 'CREATE INDEX test_idx1 ON testtbl ' + '(lower(data) text_pattern_ops)', + dialect=postgresql.dialect()) + self.assert_compile(schema.CreateIndex(idx2), + 'CREATE INDEX test_idx2 ON testtbl ' + '((xyz(data) + data2) text_pattern_ops, ' + 'data2 int4_ops)', + dialect=postgresql.dialect()) + def test_create_index_with_text_or_composite(self): m = MetaData() tbl = Table('testtbl', m, |