Skip to content

Commit 15e8ea7

Browse files
authored
Make _to_python recursive for lists and tuples (#94)
* Update pysolr.py Let _to_python work recursively on lists and tuples. * Update client.py Update tests for recursive _to_python.
1 parent dce70b4 commit 15e8ea7

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

pysolr.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,10 @@ def _to_python(self, value):
734734
return value
735735

736736
if isinstance(value, (list, tuple)):
737-
value = value[0]
737+
result = [self._to_python(v) for v in value]
738+
if isinstance(value, tuple):
739+
result = tuple(result)
740+
return result
738741

739742
if value == "true":
740743
return True

tests/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,8 @@ def test__to_python(self):
549549
self.assertEqual(self.solr._to_python(1.2), 1.2)
550550
self.assertEqual(self.solr._to_python(b"hello"), "hello")
551551
self.assertEqual(self.solr._to_python("hello ☃"), "hello ☃")
552-
self.assertEqual(self.solr._to_python(["foo", "bar"]), "foo")
553-
self.assertEqual(self.solr._to_python(("foo", "bar")), "foo")
552+
self.assertEqual(self.solr._to_python(["foo", "bar"]), ["foo", "bar"])
553+
self.assertEqual(self.solr._to_python(("foo", "bar")), ("foo", "bar"))
554554
self.assertEqual(
555555
self.solr._to_python('tuple("foo", "bar")'), 'tuple("foo", "bar")'
556556
)

0 commit comments

Comments
 (0)