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-Tag: rel_1_4_54~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2b04a6c12a58b550aea2fe462674a812b0024c04;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Include operators in postgres JSONB documentation (#11828) (cherry picked from commit 06ca61066ee312a5198cf1db869f388255212559) Change-Id: I3e432a8b14309314f4c56d43841cba464518b125 --- diff --git a/lib/sqlalchemy/dialects/postgresql/json.py b/lib/sqlalchemy/dialects/postgresql/json.py index e6b6f58677..a72a6781d9 100644 --- a/lib/sqlalchemy/dialects/postgresql/json.py +++ b/lib/sqlalchemy/dialects/postgresql/json.py @@ -294,22 +294,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. @@ -318,7 +323,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