-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
redis module version redis==7.1.0 but on older version same thing happens
Python Version 3.10.12
after using redis.json().get() redis.execute_command() returns dict not bytes
if decode_responses is True it also return dict instead of string
Here is code to recreate
import redis
from os import getenv
from dotenv import load_dotenv
load_dotenv()
REDIS_HOST=getenv("REDIS_HOST","localhost")
REDIS_PORT=getenv("REDIS_PORT",6379)
REDIS_PASSWORD=getenv("REDIS_PASSWORD","password")
r = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT, password=REDIS_PASSWORD,decode_responses=False)
raw_json = r.execute_command("JSON.GET","info")
print(f"type of info execute: {type(raw_json)}")
x= r.json().get("info")
print(f"type of info when using redis.json(): {type(x)}")
This prints
type of info execute: <class 'bytes'>
type of info when using redis.json(): <class 'dict'>
but when i run this in other order
x= r.json().get("info")
print(f"type of info when using redis.json(): {type(x)}")
raw_json = r.execute_command("JSON.GET","info")
print(f"type of info execute: {type(raw_json)}")
type of info when using redis.json(): <class 'dict'>
type of info execute: <class 'dict'>