Index postgresql_ops ignored when func.lower(column)
Here is code:
from sqlalchemy import Table, Column, Index, String, MetaData, func, create_engine
md = MetaData()
tbl = Table('t1', md, Column('col1', String()))
idx = Index('idx1', func.lower(tbl.c.col1), postgresql_ops={'col1': 'text_pattern_ops'})
e = create_engine("postgresql://postgres:postgres@localhost/test", echo=True)
with e.connect() as c:
md.create_all(c)
Outputs
Column | Type | Modifiers
--------+-------------------+-----------
col1 | character varying |
Indexes:
"idx1" btree (lower(col1::text)) # NO text_pattern_ops!!!
Comments (5)
-
repo owner -
repo owner - changed status to resolved
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→ <<cset 029d0f753852>>
-
repo owner 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(cherry picked from commit 029d0f75385298f8056c04eba1d2f9563126a8a6)→ <<cset ca7f83bf9b7d>>
-
repo owner 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(cherry picked from commit 029d0f75385298f8056c04eba1d2f9563126a8a6)→ <<cset 4120a4c79321>>
-
reporter Thank you!
- Log in to comment
please use a label():