Skip to content

Commit aef9d10

Browse files
committed
Make the update() method returns an Index object instead of a dict
1 parent 013f587 commit aef9d10

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

meilisearch/index.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,16 @@ def update(self, **body):
5555
5656
Returns
5757
-------
58-
index: dict
59-
Dictionary containing index information.
58+
index : Index
59+
An Index instance of the newly updated index.
6060
"""
6161
payload = {}
6262
primary_key = body.get('primaryKey', None)
6363
if primary_key is not None:
6464
payload['primaryKey'] = primary_key
6565
response = self.http.put('{}/{}'.format(self.config.paths.index, self.uid), payload)
6666
self.primary_key = response['primaryKey']
67-
return response
67+
return self
6868

6969
def fetch_info(self):
7070
"""Fetch the info of the index.

meilisearch/tests/index/test_index.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ def test_update_index(self):
140140
index = self.client.index(uid=self.index_uid)
141141
response = index.update(primaryKey='objectID')
142142
assert isinstance(response, object)
143+
assert response.uid == index.uid
144+
assert response.primary_key == index.primary_key
143145
assert index.primary_key == 'objectID'
144146
assert index.get_primary_key() == 'objectID'
145147

0 commit comments

Comments
 (0)