Skip to content

Commit bf7bc00

Browse files
miguelgrinberggithub-actions[bot]
authored andcommitted
Fixed regression introduced in Terms query class (#1907)
(cherry picked from commit 8a72af9)
1 parent afd340b commit bf7bc00

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Diff for: elasticsearch_dsl/query.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,10 @@ class Terms(Query):
551551
name = "terms"
552552

553553
def _setattr(self, name: str, value: Any) -> None:
554-
super()._setattr(name, list(value))
554+
# here we convert any iterables that are not strings to lists
555+
if hasattr(value, "__iter__") and not isinstance(value, (str, list)):
556+
value = list(value)
557+
super()._setattr(name, value)
555558

556559

557560
class TermsSet(Query):

Diff for: tests/test_query.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ def test_terms_to_dict() -> None:
8181
assert {"terms": {"_type": ["article", "section"]}} == query.Terms(
8282
_type=["article", "section"]
8383
).to_dict()
84-
assert {"terms": {"_type": ["article", "section"]}} == query.Terms(
85-
_type=("article", "section")
84+
assert {"terms": {"_type": ["article", "section"], "boost": 1.1}} == query.Terms(
85+
_type=("article", "section"), boost=1.1
8686
).to_dict()
8787

8888

0 commit comments

Comments
 (0)