From 7b84c850606c7b093b4260c08ff4636ff1bdbfef Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 13 Dec 2022 20:07:14 -0500 Subject: add explicit REGCONFIG, pg full text functions Added support for explicit use of PG full text functions with asyncpg and psycopg (SQLAlchemy 2.0 only), with regards to the ``REGCONFIG`` type cast for the first argument, which previously would be incorrectly cast to a VARCHAR, causing failures on these dialects that rely upon explicit type casts. This includes support for :class:`_postgresql.to_tsvector`, :class:`_postgresql.to_tsquery`, :class:`_postgresql.plainto_tsquery`, :class:`_postgresql.phraseto_tsquery`, :class:`_postgresql.websearch_to_tsquery`, :class:`_postgresql.ts_headline`, each of which will determine based on number of arguments passed if the first string argument should be interpreted as a PostgreSQL "REGCONFIG" value; if so, the argument is typed using a newly added type object :class:`_postgresql.REGCONFIG` which is then explicitly cast in the SQL expression. Fixes: #8977 Change-Id: Ib36698a984fd4194bd6e0eb663105f790f3db7d3 --- lib/sqlalchemy/dialects/postgresql/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/sqlalchemy/dialects/postgresql/__init__.py') diff --git a/lib/sqlalchemy/dialects/postgresql/__init__.py b/lib/sqlalchemy/dialects/postgresql/__init__.py index 7890541ff..d2e213bbc 100644 --- a/lib/sqlalchemy/dialects/postgresql/__init__.py +++ b/lib/sqlalchemy/dialects/postgresql/__init__.py @@ -37,6 +37,12 @@ from .dml import insert from .ext import aggregate_order_by from .ext import array_agg from .ext import ExcludeConstraint +from .ext import phraseto_tsquery +from .ext import plainto_tsquery +from .ext import to_tsquery +from .ext import to_tsvector +from .ext import ts_headline +from .ext import websearch_to_tsquery from .hstore import HSTORE from .hstore import hstore from .json import JSON @@ -72,8 +78,10 @@ from .types import MACADDR from .types import MONEY from .types import OID from .types import REGCLASS +from .types import REGCONFIG from .types import TIME from .types import TIMESTAMP +from .types import TSQUERY from .types import TSVECTOR # Alias psycopg also as psycopg_async @@ -102,6 +110,9 @@ __all__ = ( "MONEY", "OID", "REGCLASS", + "REGCONFIG", + "TSQUERY", + "TSVECTOR", "DOUBLE_PRECISION", "TIMESTAMP", "TIME", -- cgit v1.2.1