From 2f100a11fcb94dbc4e4098dd9a79facb5fd043f7 Mon Sep 17 00:00:00 2001 From: Firas rabaia <44394489+firas-rabaia@users.noreply.github.com> Date: Wed, 4 Sep 2024 12:10:41 +0300 Subject: [PATCH] fix client util escape function casting int, float to a string client util escape function casting int, float to a string but it should keep it as the passed value since it causes exceptions to be raised like in opensearchpy.client.OpenSearch.delete_by_query when passing the field as a normal parameter for the function. Signed-off-by: Firas rabaia <44394489+firas-rabaia@users.noreply.github.com> --- opensearchpy/client/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opensearchpy/client/utils.py b/opensearchpy/client/utils.py index d7fd5c5a..02491a6f 100644 --- a/opensearchpy/client/utils.py +++ b/opensearchpy/client/utils.py @@ -102,8 +102,8 @@ def _escape(value: Any) -> Any: elif isinstance(value, bool): value = str(value).lower() - # don't decode bytestrings - elif isinstance(value, bytes): + # don't decode bytestrings, int, float + elif isinstance(value, (bytes, int, float)): return value # encode strings to utf-8