Added optional columns and options parameters to 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.22 (2013-10-03)
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
- Added optional columns and options parameter for TSVectorType
|
||||
|
||||
|
||||
0.16.21 (2013-09-29)
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
2
setup.py
2
setup.py
@@ -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',
|
||||
|
@@ -38,7 +38,7 @@ from .types import (
|
||||
)
|
||||
|
||||
|
||||
__version__ = '0.16.21'
|
||||
__version__ = '0.16.22'
|
||||
|
||||
|
||||
__all__ = (
|
||||
|
@@ -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.
|
||||
"""
|
||||
|
@@ -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'
|
||||
|
Reference in New Issue
Block a user