class FullTextSearchObject(FullTextSearchMixin, DeclarativeBase):
    __tablename__ = 'fulltext_search_object'

    id = Field(Integer, primary_key=True)
    title = Field(Unicode(50))

    __ts_vector__ = to_tsvector(title)
Beispiel #2
0
class Person(FullTextSearchMixin, DeclarativeBase):
    __tablename__ = 'person'

    id = Field(Integer, primary_key=True)
    first_name = Field(Unicode(50))
    last_name = Field(Unicode(50))
    description = Field(Text)

    __ts_vector__ = to_tsvector(
        first_name, last_name, description
    )

    __table_args__ = (
        Index('idx_person_fts', __ts_vector__, postgresql_using='gin'),
        Index('idx_first_name_trgm', text("first_name gin_trgm_ops"), postgresql_using='gin')
    )
def test_to_tsvector(db):
    result = to_tsvector('a', 'b', 'c')
    assert str(result) == 'to_tsvector(:to_tsvector_1, :to_tsvector_2)'
Beispiel #4
0
 def test_to_tsvector(self):
     result = to_tsvector('a', 'b', 'c')
     self.assertEqual(str(result),
                      'to_tsvector(:to_tsvector_1, :to_tsvector_2)')