Skip to content

Commit 4ca871d

Browse files
committed
IGNITE-14058: Bool arrays now return as bool array, not int array
This closes #4
1 parent 644de99 commit 4ca871d

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

pyignite/datatypes/primitive_arrays.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,12 @@ class BoolArrayObject(PrimitiveArrayObject):
297297
_type_id = TYPE_BOOLEAN_ARR
298298
primitive_type = Bool
299299
type_code = TC_BOOL_ARRAY
300+
301+
@classmethod
302+
def to_python(cls, ctype_object, *args, **kwargs):
303+
if not ctype_object:
304+
return None
305+
result = [False] * ctype_object.length
306+
for i in range(ctype_object.length):
307+
result[i] = ctype_object.data[i] != 0
308+
return result

tests/test_datatypes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
6666
# array of bool
6767
([True, False, True], None),
68+
([True, False], BoolArrayObject),
69+
([False, True], BoolArrayObject),
70+
([True, False, True, False], BoolArrayObject),
6871
6972
# string
7073
('Little Mary had a lamb', None),
@@ -140,6 +143,10 @@ def test_put_get_data(client, cache, value, value_hint):
140143
assert result.status == 0
141144
assert result.value == value
142145

146+
if isinstance(result.value, list):
147+
for res, val in zip(result.value, value):
148+
assert type(res) == type(val)
149+
143150

144151
@pytest.mark.parametrize(
145152
'value',

0 commit comments

Comments
 (0)