10
10
)
11
11
12
12
# Base request structures that are shared between DDB and dict formats
13
+ # Use ConsistentRead: True for all requests;
14
+ # many of these are used in integ tests, where consistent reads reduce test flakiness.
13
15
14
16
15
17
def base_put_item_request (item ):
@@ -19,7 +21,7 @@ def base_put_item_request(item):
19
21
20
22
def base_get_item_request (item ):
21
23
"""Base structure for get_item requests."""
22
- return {"Key" : {"partition_key" : item ["partition_key" ], "sort_key" : item ["sort_key" ]}}
24
+ return {"Key" : {"partition_key" : item ["partition_key" ], "sort_key" : item ["sort_key" ]}, "ConsistentRead" : True }
23
25
24
26
25
27
def base_delete_item_request (item ):
@@ -32,6 +34,7 @@ def base_query_request(item):
32
34
return {
33
35
"KeyConditionExpression" : "partition_key = :pk" ,
34
36
"ExpressionAttributeValues" : {":pk" : item ["partition_key" ]},
37
+ "ConsistentRead" : True ,
35
38
}
36
39
37
40
@@ -40,6 +43,7 @@ def base_scan_request(item):
40
43
return {
41
44
"FilterExpression" : "attribute2 = :a2" ,
42
45
"ExpressionAttributeValues" : {":a2" : item ["attribute2" ]},
46
+ "ConsistentRead" : True ,
43
47
}
44
48
45
49
@@ -50,7 +54,7 @@ def base_batch_write_item_request(actions_with_items):
50
54
51
55
def base_batch_get_item_request (keys ):
52
56
"""Base structure for batch_get_item requests."""
53
- return {"RequestItems" : {INTEG_TEST_DEFAULT_DYNAMODB_TABLE_NAME : {"Keys" : keys }}}
57
+ return {"RequestItems" : {INTEG_TEST_DEFAULT_DYNAMODB_TABLE_NAME : {"Keys" : keys , "ConsistentRead" : True }}}
54
58
55
59
56
60
def base_transact_write_item_request (actions_with_items ):
0 commit comments