Skip to content

Commit 8325e6e

Browse files
melderdvora-h
andauthored
Fixes issue decode_responses is set to True regardless if REDIS_OM_UR… (#373)
Fixes issue decode_responses is set to True regardless if REDIS_OM_URL environment variable is set. Otherwise these warnings pop up when persisting objects: Could not parse Redis response. Error was: "keywords must be strings". Probably, the connection is not set to decode responses from bytes. Attempting to decode response using the encoding set on model class (<class 'redis_om.model.model.ModelMeta'>. Encoding: utf-8. Co-authored-by: dvora-h <[email protected]>
1 parent 9e17678 commit 8325e6e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

aredis_om/connections.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77

88

99
def get_redis_connection(**kwargs) -> redis.Redis:
10+
# Decode from UTF-8 by default
11+
if "decode_responses" not in kwargs:
12+
kwargs["decode_responses"] = True
13+
1014
# If someone passed in a 'url' parameter, or specified a REDIS_OM_URL
1115
# environment variable, we'll create the Redis client from the URL.
1216
url = kwargs.pop("url", URL)
1317
if url:
1418
return redis.Redis.from_url(url, **kwargs)
1519

16-
# Decode from UTF-8 by default
17-
if "decode_responses" not in kwargs:
18-
kwargs["decode_responses"] = True
1920
return redis.Redis(**kwargs)

0 commit comments

Comments
 (0)