Added match operator for TSVectorType
This commit is contained in:
@@ -4,6 +4,12 @@ Changelog
|
||||
Here you can see the full list of changes between each SQLAlchemy-Utils release.
|
||||
|
||||
|
||||
0.16.23 (2013-10-04)
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
- Added match operator for TSVectorType
|
||||
|
||||
|
||||
0.16.22 (2013-10-03)
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
2
setup.py
2
setup.py
@@ -56,7 +56,7 @@ for name, requirements in extras_require.items():
|
||||
|
||||
setup(
|
||||
name='SQLAlchemy-Utils',
|
||||
version='0.16.22',
|
||||
version='0.16.23',
|
||||
url='https://github.com/kvesteri/sqlalchemy-utils',
|
||||
license='BSD',
|
||||
author='Konsta Vesterinen, Ryan Leckey, Janne Vanhala, Vesa Uimonen',
|
||||
|
@@ -38,7 +38,7 @@ from .types import (
|
||||
)
|
||||
|
||||
|
||||
__version__ = '0.16.22'
|
||||
__version__ = '0.16.23'
|
||||
|
||||
|
||||
__all__ = (
|
||||
|
@@ -3,6 +3,12 @@ from sqlalchemy.dialects.postgresql.base import ischema_names
|
||||
|
||||
|
||||
class TSVectorType(sa.types.UserDefinedType):
|
||||
class comparator_factory(sa.types.TypeEngine.Comparator):
|
||||
def match(self, other):
|
||||
from sqlalchemy_utils.expressions import tsvector_match
|
||||
|
||||
return tsvector_match(self.expr, other)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""
|
||||
Initializes new TSVectorType
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import six
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy_utils import TSVectorType
|
||||
from tests import TestCase
|
||||
@@ -35,3 +36,8 @@ class TestTSVector(TestCase):
|
||||
type_ = TSVectorType('name', 'age', catalog='pg_catalog.simple')
|
||||
assert type_.columns == ('name', 'age')
|
||||
assert type_.options['catalog'] == 'pg_catalog.simple'
|
||||
|
||||
def test_match(self):
|
||||
assert six.text_type(self.User.search_index.match(u'something')) == (
|
||||
'("user".search_index) @@ :tsvector_match_1'
|
||||
)
|
||||
|
Reference in New Issue
Block a user