- changed status to duplicate
Unable to create tsvector functional index
Issue #2800
resolved
class Organization(Base):
__tablename__ = 'organization'
id = Column(Integer, primary_key=True)
name = Column(Unicode, unique=True)
business_number = Column(Unicode(255), unique=True)
website = Column(Unicode)
is_donor = Column(Boolean, nullable=False, default=False)
is_member = Column(Boolean, nullable=False, default=False)
__table_args__ = (
Index(
'organization_name_search_ix',
func.to_tsvector('english', func.lower(name)),
postgresql_using='gin'
),
)
Produces the following mangled SQL output:
2013-08-14 15:56:58,170 INFO [sqlalchemy.engine.base.Engine](sqlalchemy.engine.base.Engine)[MainThread](MainThread) {}
2013-08-14 15:56:58,191 INFO [sqlalchemy.engine.base.Engine](sqlalchemy.engine.base.Engine)[MainThread](MainThread) COMMIT
2013-08-14 15:56:58,194 INFO [sqlalchemy.engine.base.Engine](sqlalchemy.engine.base.Engine)[MainThread](MainThread) CREATE INDEX organization_name_search_ix ON organization USING gin (to_tsvector(%(to_tsvector_1)s, lower(name)))
2013-08-14 15:56:58,194 INFO [sqlalchemy.engine.base.Engine](sqlalchemy.engine.base.Engine)[MainThread](MainThread) {}
2013-08-14 15:56:58,194 INFO [sqlalchemy.engine.base.Engine](sqlalchemy.engine.base.Engine)[MainThread](MainThread) ROLLBACK
Comments (1)
-
repo owner - Log in to comment
you can't use bound parameters in DDL,
#2742looks to improve this so this is a duplicate.