Skip to content

Commit 18b2aee

Browse files
isapegobojidar-bg
andauthored
GG-33663 IGNITE-15266 Fix nested object arrays deserialization (#56)
(cherry picked from commit be18440) Co-authored-by: Bojidar Marinov <[email protected]>
1 parent 4c9207a commit 18b2aee

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

pygridgain/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ def is_hinted(value):
6666
"""
6767
Check if a value is a tuple of data item and its type hint.
6868
"""
69-
return isinstance(value, tuple) and len(value) == 2 and issubclass(value[1], GridGainDataType)
69+
return isinstance(value, tuple) and len(value) == 2 and inspect.isclass(value[1]) and \
70+
issubclass(value[1], GridGainDataType)
7071

7172

7273
def int_overflow(value: int) -> int:

tests/common/test_datatypes.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,41 @@ async def test_put_get_data_async(async_cache, value, value_hint):
166166
assert await async_cache.get('my_key') == value
167167

168168

169+
nested_array_objects_params = [
170+
[
171+
(ObjectArrayObject.OBJECT, [
172+
((ObjectArrayObject.OBJECT, [
173+
'test', 1, Value(1, 'test'),
174+
((ObjectArrayObject.OBJECT, ['test', 1, Value(1, 'test')]), ObjectArrayObject)
175+
]), ObjectArrayObject)
176+
]),
177+
(ObjectArrayObject.OBJECT, [
178+
(ObjectArrayObject.OBJECT, ['test', 1, Value(1, 'test'),
179+
(ObjectArrayObject.OBJECT, ['test', 1, Value(1, 'test')])])
180+
])
181+
],
182+
]
183+
184+
185+
@pytest.mark.parametrize(
186+
'hinted_value, value',
187+
nested_array_objects_params
188+
)
189+
def test_put_get_nested_array_objects(cache, hinted_value, value):
190+
cache.put('my_key', hinted_value, value_hint=ObjectArrayObject)
191+
assert cache.get('my_key') == value
192+
193+
194+
@pytest.mark.parametrize(
195+
'hinted_value, value',
196+
nested_array_objects_params
197+
)
198+
@pytest.mark.asyncio
199+
async def test_put_get_nested_array_objects_async(async_cache, hinted_value, value):
200+
await async_cache.put('my_key', hinted_value, value_hint=ObjectArrayObject)
201+
assert await async_cache.get('my_key') == value
202+
203+
169204
bytearray_params = [
170205
([1, 2, 3, 5], ByteArrayObject),
171206
((7, 8, 13, 18), ByteArrayObject),

0 commit comments

Comments
 (0)