12
12
from smithy_dafny_standard_library .internaldafny .generated import Wrappers
13
13
from aws_dbesdk_dynamodb .smithygenerated .aws_cryptography_dbencryptionsdk_dynamodb .errors import _smithy_error_to_dafny_error
14
14
from aws_dbesdk_dynamodb_test_vectors .waiting_boto3_ddb_client import WaitingLocalDynamoClient
15
- from aws_dbesdk_dynamodb .transform import (
16
- dict_to_ddb ,
17
- ddb_to_dict ,
18
- )
19
- from aws_dbesdk_dynamodb .internal import client_to_resource
20
-
21
- from boto3 .dynamodb .conditions import Key , Attr , And , Or , Not , Contains
22
- from boto3 .dynamodb .types import TypeDeserializer
23
15
24
- # from .....test.resource_formatted_queries import (queries, complex_queries)
16
+ from boto3 . dynamodb . conditions import Key , Attr
25
17
26
18
# When querying, DBESDK DDB TestVectors will pass the Table the query as a string.
27
19
# The Table could accept this string as-is and process it correctly.
28
20
# However, EncryptedTables have extra logic to process boto3 Conditions.
29
- # I want to test this extra logic as much as possible.
21
+ # This extra logic should be tested as much as possible.
30
22
# This map converts some known query strings to equivalent Conditions.
31
23
# TestVectors will pass the query string (map key) to the Table;
32
24
# the Table's internal logic will look up the query string in this map:
33
25
# - Entry found: Query with replaced Condition
34
26
# - Not found: Query with original string. Table accepts strings.
35
27
# This map contains all query strings in the TestVectors' data.json as of commit
36
28
# 4f18689f79243c9a5ab0f3a23108671defddeac4
37
- # If any query strings are added to TestVectors, they COULD be added here,
38
- # but do not need to be added .
29
+ # If any query strings are added to TestVectors, they COULD be added here;
30
+ # if they are not added, the Table will accept the string as-is .
39
31
known_query_string_to_condition_map = {
40
32
# "Basic" queries
41
33
"RecNum = :zero" : Key ("RecNum" ).eq (":zero" ),
@@ -130,9 +122,9 @@ def get_item(self, **kwargs):
130
122
return client_output
131
123
132
124
def batch_write_item (self , ** kwargs ):
133
- # There isn't a resource shape for this;
125
+ # The table doesn't support batch_write_item, but supports batch_writer.
126
+ # Translate the batch_write_item request to batch_writer requests.
134
127
table_input = self ._client_shape_to_resource_shape_converter .batch_write_item_request (kwargs )
135
- # table_output = self._table.batch_write_item(**table_input)
136
128
with self ._table .batch_writer () as batch_writer :
137
129
for _ , items in table_input ["RequestItems" ].items ():
138
130
for item in items :
@@ -142,7 +134,7 @@ def batch_write_item(self, **kwargs):
142
134
batch_writer .delete_item (item ["DeleteRequest" ]["Key" ])
143
135
else :
144
136
raise ValueError (f"Unknown request type: { item } " )
145
- # There isn't a shape for the output, but luckily the output can be an empty dict :
137
+ # An empty dict is valid output:
146
138
# https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb/client/batch_write_item.html
147
139
client_output = {}
148
140
return client_output
@@ -158,8 +150,7 @@ def scan(self, **kwargs):
158
150
if "KeyConditionExpression" in table_input :
159
151
if table_input ["KeyConditionExpression" ] in known_query_string_to_condition_map :
160
152
# Turn the query into the resource-formatted query
161
- query = known_query_string_to_condition_map [table_input ["KeyConditionExpression" ]]
162
- table_input ["KeyConditionExpression" ] = query
153
+ table_input ["KeyConditionExpression" ] = known_query_string_to_condition_map [table_input ["KeyConditionExpression" ]]
163
154
if "FilterExpression" in table_input :
164
155
if table_input ["FilterExpression" ] in known_query_string_to_condition_map :
165
156
# Turn the query into the resource-formatted query
@@ -182,8 +173,7 @@ def query(self, **kwargs):
182
173
if "KeyConditionExpression" in table_input :
183
174
if table_input ["KeyConditionExpression" ] in known_query_string_to_condition_map :
184
175
# Turn the query into the resource-formatted query
185
- query = known_query_string_to_condition_map [table_input ["KeyConditionExpression" ]]
186
- table_input ["KeyConditionExpression" ] = query
176
+ table_input ["KeyConditionExpression" ] = known_query_string_to_condition_map [table_input ["KeyConditionExpression" ]]
187
177
if "FilterExpression" in table_input :
188
178
if table_input ["FilterExpression" ] in known_query_string_to_condition_map :
189
179
# Turn the query into the resource-formatted query
0 commit comments