Skip to content

Commit cd742c8

Browse files
authored
Merge pull request #398 from splunk/DVPL-10032
Updated kvstore method
2 parents ba05bb9 + a4039cd commit cd742c8

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

examples/kvstore.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ def main():
8080

8181
query = json.dumps({"otherkey": "bar"})
8282
print("Should return third item with auto-generated _key: %s" % json.dumps(collection.data.query(query=query), indent=1))
83-
83+
84+
# passing query data as dict
85+
query = {"somekey": {"$gt": 1}}
86+
print("Should return item2 and item3: %s" % json.dumps(collection.data.query(query=query), indent=1))
87+
8488
# Let's delete the collection
8589
collection.delete()
8690

splunklib/client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3640,6 +3640,11 @@ def query(self, **query):
36403640
:return: Array of documents retrieved by query.
36413641
:rtype: ``array``
36423642
"""
3643+
3644+
for key, value in query.items():
3645+
if isinstance(query[key], dict):
3646+
query[key] = json.dumps(value)
3647+
36433648
return json.loads(self._get('', **query).body.read().decode('utf-8'))
36443649

36453650
def query_by_id(self, id):

0 commit comments

Comments
 (0)