From: Jimmy AUDEBERT <109511155+jaudebert@users.noreply.github.com> Date: Wed, 4 Sep 2024 17:23:53 +0000 (+0200) Subject: Include operators in postgres JSONB documentation (#11828) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=06ca61066ee312a5198cf1db869f388255212559;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Include operators in postgres JSONB documentation (#11828) --- diff --git a/lib/sqlalchemy/dialects/postgresql/json.py b/lib/sqlalchemy/dialects/postgresql/json.py index 3790fa359b..1cdafbd03d 100644 --- a/lib/sqlalchemy/dialects/postgresql/json.py +++ b/lib/sqlalchemy/dialects/postgresql/json.py @@ -256,22 +256,27 @@ class JSONB(JSON): """Define comparison operations for :class:`_types.JSON`.""" def has_key(self, other): - """Boolean expression. Test for presence of a key. Note that the - key may be a SQLA expression. + """Boolean expression. Test for presence of a key (equivalent of + the ``?`` operator). Note that the key may be a SQLA expression. """ return self.operate(HAS_KEY, other, result_type=sqltypes.Boolean) def has_all(self, other): - """Boolean expression. Test for presence of all keys in jsonb""" + """Boolean expression. Test for presence of all keys in jsonb + (equivalent of the ``?&`` operator) + """ return self.operate(HAS_ALL, other, result_type=sqltypes.Boolean) def has_any(self, other): - """Boolean expression. Test for presence of any key in jsonb""" + """Boolean expression. Test for presence of any key in jsonb + (equivalent of the ``?|`` operator) + """ return self.operate(HAS_ANY, other, result_type=sqltypes.Boolean) def contains(self, other, **kwargs): """Boolean expression. Test if keys (or array) are a superset - of/contained the keys of the argument jsonb expression. + of/contained the keys of the argument jsonb expression + (equivalent of the ``@>`` operator). kwargs may be ignored by this operator but are required for API conformance. @@ -280,7 +285,8 @@ class JSONB(JSON): def contained_by(self, other): """Boolean expression. Test if keys are a proper subset of the - keys of the argument jsonb expression. + keys of the argument jsonb expression + (equivalent of the ``<@`` operator). """ return self.operate( CONTAINED_BY, other, result_type=sqltypes.Boolean @@ -288,7 +294,7 @@ class JSONB(JSON): def delete_path(self, array): """JSONB expression. Deletes field or array element specified in - the argument array. + the argument array (equivalent of the ``#-`` operator). The input may be a list of strings that will be coerced to an ``ARRAY`` or an instance of :meth:`_postgres.array`. @@ -302,7 +308,7 @@ class JSONB(JSON): def path_exists(self, other): """Boolean expression. Test for presence of item given by the - argument JSONPath expression. + argument JSONPath expression (equivalent of the ``@?`` operator). .. versionadded:: 2.0 """ @@ -312,7 +318,8 @@ class JSONB(JSON): def path_match(self, other): """Boolean expression. Test if JSONPath predicate given by the - argument JSONPath expression matches. + argument JSONPath expression matches + (equivalent of the ``@@`` operator). Only the first item of the result is taken into account.