From 923ab4f665c444da79d4b798cdb2fa9740f15516 Mon Sep 17 00:00:00 2001 From: JackiLin Date: Wed, 4 Sep 2024 13:52:20 +0800 Subject: [PATCH 1/2] Fix parsing of the is_master attribute in the URL --- redis/connection.py | 1 + 1 file changed, 1 insertion(+) diff --git a/redis/connection.py b/redis/connection.py index 1f862d0371..61ef1e8ffa 100644 --- a/redis/connection.py +++ b/redis/connection.py @@ -956,6 +956,7 @@ def to_bool(value): "health_check_interval": int, "ssl_check_hostname": to_bool, "timeout": float, + "is_master": to_bool, } From c2d8c600a56787851543eacc2f0f88242740ae23 Mon Sep 17 00:00:00 2001 From: JackiLin Date: Sun, 22 Sep 2024 13:26:56 +0800 Subject: [PATCH 2/2] Add test case for Redis URL parsing with read-write separation --- tests/test_connection_pool.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_connection_pool.py b/tests/test_connection_pool.py index dee7c554d3..c2a590c5c4 100644 --- a/tests/test_connection_pool.py +++ b/tests/test_connection_pool.py @@ -321,6 +321,11 @@ def test_extra_querystring_options(self): assert pool.connection_class == redis.Connection assert pool.connection_kwargs == {"host": "localhost", "a": "1", "b": "2"} + def test_ismaster_querystring(self): + pool = redis.ConnectionPool.from_url("redis://localhost?1&ismaster=0") + assert pool.connection_class == redis.Connection + assert pool.connection_kwargs == {"host": "localhost", "db": 1,"ismaster": False} + def test_calling_from_subclass_returns_correct_instance(self): pool = redis.BlockingConnectionPool.from_url("redis://localhost") assert isinstance(pool, redis.BlockingConnectionPool)