summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/base.py
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2022-08-02 12:27:57 +0200
committerMike Bayer <mike_mp@zzzcomputing.com>2022-08-17 11:50:24 -0400
commit2e7117ab1b584e678380c70625ad1331cea551d0 (patch)
tree8defd69fd3202159842511dfc4e9d22e21ad9e7a /lib/sqlalchemy/dialects/postgresql/base.py
parenta134ec1760df6295d537ff63df7aee83d957bf6a (diff)
downloadsqlalchemy-2e7117ab1b584e678380c70625ad1331cea551d0.tar.gz
JSONPATH type can be used in casts in PostgreSQL
Introduced the type :class:`_postgresql.JSONPATH` that can be used in cast expressions. This is required by some PostgreSQL dialects when using functions such as ``jsonb_path_exists`` or ``jsonb_path_match`` that accept a ``jsonpath`` as input. Fixes: #8216 Change-Id: I3e7337eab91680cab1604e1f3058854a0a19c5be
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 35a09cfa7..75fa3d7c7 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -1512,7 +1512,7 @@ colspecs = {
sqltypes.ARRAY: _array.ARRAY,
sqltypes.Interval: INTERVAL,
sqltypes.Enum: ENUM,
- sqltypes.JSON.JSONPathType: _json.JSONPathType,
+ sqltypes.JSON.JSONPathType: _json.JSONPATH,
sqltypes.JSON: _json.JSON,
UUID: PGUuid,
}
@@ -2503,6 +2503,12 @@ class PGTypeCompiler(compiler.GenericTypeCompiler):
count=1,
)
+ def visit_json_path(self, type_, **kw):
+ return self.visit_JSONPATH(type_, **kw)
+
+ def visit_JSONPATH(self, type_, **kw):
+ return "JSONPATH"
+
class PGIdentifierPreparer(compiler.IdentifierPreparer):