Skip to content

Commit c9c9a41

Browse files
committed
wip
1 parent feda23a commit c9c9a41

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

dynolayer/dynolayer.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ def __init__(
2626
self._offset = False
2727
self._order_by = {}
2828
self._count = 0
29-
self._secondary_index = None
30-
self._attributes_to_get = None
31-
self._filter_expression = None
32-
self._filter_params = None
29+
self._secondary_index = ''
30+
self._attributes_to_get = ''
31+
self._filter_expression = ''
32+
self._filter_params = {}
3333
self._filter_params_name = {}
3434
self._last_evaluated_key = {}
3535
self._error = ''
@@ -150,13 +150,13 @@ def find_by(
150150
if isinstance(attribute_value, dict) or isinstance(attribute_value, list):
151151
attribute_value = json.dumps(attribute_value)
152152

153-
self._filter_expression = f'#{attribute} {comparator} :{attribute}'
154-
self._filter_params = {
153+
self._filter_expression += f'#{attribute} {comparator} :{attribute}'
154+
self._filter_params.update({
155155
f':{attribute}': attribute_value
156-
}
157-
self._filter_params_name = {
156+
})
157+
self._filter_params_name.update({
158158
f'#{attribute}': attribute
159-
}
159+
})
160160

161161
return self
162162

@@ -266,6 +266,7 @@ def _fetch(self, paginate_through_results: bool = False, just_count=False, objec
266266
if self._secondary_index:
267267
scan_params.update({'IndexName': self._secondary_index})
268268

269+
self._is_find_by = False # return to default value
269270
if self._is_query_operation:
270271
return self._order_response(self._fetch_query(scan_params, paginate_through_results), object=object)
271272

tests/unit/test_find.py

+3
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ def test_it_should_find_a_collection_of_records_by_filter():
134134
assert response_find_by[0].data().get('last_name', None)
135135
assert response_find_by[0].data().get('stars', None)
136136

137+
response_by_id = user.find_by_id('123456').attributes_to_get('name').fetch(object=True)
138+
assert response_find_by
139+
137140

138141
@mock_aws
139142
def test_it_should_paginate():

0 commit comments

Comments
 (0)