]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Updates documentation for tsvector type.
authorNoufal Ibrahim <noufal@nibrahim.net.in>
Thu, 5 Dec 2013 12:51:49 +0000 (18:21 +0530)
committerNoufal Ibrahim <noufal@nibrahim.net.in>
Mon, 9 Dec 2013 19:37:36 +0000 (01:07 +0530)
Signed-off-by: Noufal Ibrahim <noufal@nibrahim.net.in>
doc/build/dialects/postgresql.rst
lib/sqlalchemy/dialects/postgresql/base.py

index c5a28bacfbfbdacba44db4ac9a49ad88ecd1cf01..4fbbf52b6a884cb6bf859bbc55e35e4fa5ea743b 100644 (file)
@@ -17,7 +17,7 @@ they originate from :mod:`sqlalchemy.types` or from the local dialect::
         DOUBLE_PRECISION, ENUM, FLOAT, HSTORE, INET, INTEGER, \
         INTERVAL, MACADDR, NUMERIC, REAL, SMALLINT, TEXT, TIME, \
         TIMESTAMP, UUID, VARCHAR, INT4RANGE, INT8RANGE, NUMRANGE, \
-        DATERANGE, TSRANGE, TSTZRANGE
+        DATERANGE, TSRANGE, TSTZRANGE, TSVECTOR
 
 Types which are specific to PostgreSQL, or have PostgreSQL-specific
 construction arguments, are as follows:
@@ -77,6 +77,8 @@ construction arguments, are as follows:
 .. autoclass:: REAL
     :members: __init__
 
+.. autoclass:: TSVECTOR
+    :members: __init__
 
 .. autoclass:: UUID
     :members: __init__
index 5ef16c412a25d7220e2a7968806041375da6c112..ed8a8c90f396428346b03006296a906bb2049739 100644 (file)
@@ -369,6 +369,31 @@ 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'
 
 
@@ -1169,7 +1194,7 @@ class PGDDLCompiler(compiler.DDLCompiler):
 class PGTypeCompiler(compiler.GenericTypeCompiler):
     def visit_TSVECTOR(self, type):
         return "TSVECTOR"
-    
+
     def visit_INET(self, type_):
         return "INET"