Added optional columns and options parameters to TSVectorType

This commit is contained in:
Konsta Vesterinen
2013-10-03 11:38:52 +03:00
parent fcf7e227da
commit da5cb7c386
5 changed files with 23 additions and 2 deletions

View File

@@ -4,6 +4,12 @@ Changelog
Here you can see the full list of changes between each SQLAlchemy-Utils release.
0.16.22 (2013-10-03)
^^^^^^^^^^^^^^^^^^^^
- Added optional columns and options parameter for TSVectorType
0.16.21 (2013-09-29)
^^^^^^^^^^^^^^^^^^^^

View File

@@ -56,7 +56,7 @@ for name, requirements in extras_require.items():
setup(
name='SQLAlchemy-Utils',
version='0.16.21',
version='0.16.22',
url='https://github.com/kvesteri/sqlalchemy-utils',
license='BSD',
author='Konsta Vesterinen, Ryan Leckey, Janne Vanhala, Vesa Uimonen',

View File

@@ -38,7 +38,7 @@ from .types import (
)
__version__ = '0.16.21'
__version__ = '0.16.22'
__all__ = (

View File

@@ -3,6 +3,16 @@ from sqlalchemy.dialects.postgresql.base import ischema_names
class TSVectorType(sa.types.UserDefinedType):
def __init__(self, *args, **kwargs):
"""
Initializes new TSVectorType
:param *args: list of column names
:param **kwargs: various other options for this TSVectorType
"""
self.columns = args
self.options = kwargs
"""
Text search vector type for postgresql.
"""

View File

@@ -30,3 +30,8 @@ class TestTSVector(TestCase):
autoload_with=self.engine
)
assert isinstance(table.c['search_index'].type, TSVectorType)
def test_catalog_and_columns_as_args(self):
type_ = TSVectorType('name', 'age', catalog='pg_catalog.simple')
assert type_.columns == ('name', 'age')
assert type_.options['catalog'] == 'pg_catalog.simple'