summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/base.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-12-09 21:01:26 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2013-12-09 21:01:26 -0500
commitd5a86d8f86c0eef8968c8915be19b94ad4682151 (patch)
tree91e4d0287d4403a05a2ae27bff987ccaf77b12b1 /lib/sqlalchemy/dialects/postgresql/base.py
parent111c61546c6e312467360441e82caf979c505fe6 (diff)
parentd3b65cd9bc118a5653246dfa0e179add7249703f (diff)
downloadsqlalchemy-d5a86d8f86c0eef8968c8915be19b94ad4682151.tar.gz
Merge branch 'tsvector' of https://bitbucket.org/nibrahim/sqlalchemy/branch/tsvector into tsvector
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index b80f269c1..7602304f8 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -368,6 +368,35 @@ class UUID(sqltypes.TypeEngine):
PGUuid = UUID
+class TSVECTOR(sqltypes.TypeEngine):
+ """The TSVECTOR type implements the Postgresql text search type
+ TSVECTOR.
+
+ It can be used to do full text queries on natural language
+ *documents*.
+
+ Search queries are performed using the ``@@`` operator in
+ postgresql. This is made available with the ``match`` method
+ available on the column.
+
+ This means that if you have a table ``Example`` with a column
+ ``text`` of type ``TSVECTOR``, you can create a search clause like
+ so
+
+ ::
+
+ Example.text.match("search string")
+
+ which will be compiled to
+
+ ::
+
+ text @@ to_tsquery('search string')
+
+ """
+ __visit_name__ = 'TSVECTOR'
+
+
class _Slice(expression.ColumnElement):
__visit_name__ = 'slice'
@@ -913,6 +942,7 @@ ischema_names = {
'interval': INTERVAL,
'interval year to month': INTERVAL,
'interval day to second': INTERVAL,
+ 'tsvector' : TSVECTOR
}
@@ -1163,6 +1193,9 @@ class PGDDLCompiler(compiler.DDLCompiler):
class PGTypeCompiler(compiler.GenericTypeCompiler):
+ def visit_TSVECTOR(self, type):
+ return "TSVECTOR"
+
def visit_INET(self, type_):
return "INET"