28
28
# 4f18689f79243c9a5ab0f3a23108671defddeac4
29
29
# If any query strings are added to TestVectors, they COULD be added here;
30
30
# if they are not added, the Table will accept the string as-is.
31
- known_query_string_to_condition_map = {
31
+ known_filter_expression_string_to_condition_map = {
32
32
# "Basic" queries
33
33
"RecNum = :zero" : Attr ("RecNum" ).eq (":zero" ),
34
- "RecNum = :one" : Attr ("RecNum" ).eq (":one" ),
35
34
"RecNum <= :zero" : Attr ("RecNum" ).lte (":zero" ),
36
35
"RecNum > :zero" : Attr ("RecNum" ).gt (":zero" ),
37
36
"RecNum >= :zero" : Attr ("RecNum" ).gte (":zero" ),
87
86
":cmp1c <= Comp1" : ":cmp1c <= Comp1" ,
88
87
}
89
88
89
+ # KeyConditionExpression strings expect Keys, not Attrs.
90
+ known_key_condition_expression_string_to_condition_map = {
91
+ "RecNum = :zero" : Key ("RecNum" ).eq (":zero" ),
92
+ "RecNum = :one" : Key ("RecNum" ).eq (":one" ),
93
+ }
94
+
90
95
class DynamoDBClientWrapperForDynamoDBTable :
91
96
"""
92
97
DBESDK TestVectors-internal wrapper class.
@@ -147,15 +152,20 @@ def scan(self, **kwargs):
147
152
# convert the string-based KeyConditionExpression and FilterExpression
148
153
# into the boto3.conditions.Key and boto3.conditions.Attr resource-formatted queries.
149
154
if "KeyConditionExpression" in table_input :
150
- if table_input ["KeyConditionExpression" ] in known_query_string_to_condition_map :
151
- # Turn the query into the resource-formatted query
152
- print (f"Converting { table_input ['KeyConditionExpression' ]} to { known_query_string_to_condition_map [table_input ['KeyConditionExpression' ]]} " )
153
- table_input ["KeyConditionExpression" ] = known_query_string_to_condition_map [table_input ["KeyConditionExpression" ]]
155
+ if table_input ["KeyConditionExpression" ] in known_key_condition_expression_string_to_condition_map :
156
+ table_input ["KeyConditionExpression" ] = known_key_condition_expression_string_to_condition_map [table_input ["KeyConditionExpression" ]]
157
+ else :
158
+ # Pass the original string through.
159
+ # The table will accept the string as-is.
160
+ pass
154
161
if "FilterExpression" in table_input :
155
- if table_input ["FilterExpression" ] in known_query_string_to_condition_map :
162
+ if table_input ["FilterExpression" ] in known_filter_expression_string_to_condition_map :
156
163
# Turn the query into the resource-formatted query
157
- print (f"Converting { table_input ['FilterExpression' ]} to { known_query_string_to_condition_map [table_input ['FilterExpression' ]]} " )
158
- table_input ["FilterExpression" ] = known_query_string_to_condition_map [table_input ["FilterExpression" ]]
164
+ table_input ["FilterExpression" ] = known_filter_expression_string_to_condition_map [table_input ["FilterExpression" ]]
165
+ else :
166
+ # Pass the original string through.
167
+ # The table will accept the string as-is.
168
+ pass
159
169
table_output = self ._table .scan (** table_input )
160
170
client_output = self ._resource_shape_to_client_shape_converter .scan_response (table_output )
161
171
return client_output
@@ -172,15 +182,20 @@ def query(self, **kwargs):
172
182
# convert the string-based KeyConditionExpression and FilterExpression
173
183
# into the boto3.conditions.Key and boto3.conditions.Attr resource-formatted queries.
174
184
if "KeyConditionExpression" in table_input :
175
- if table_input ["KeyConditionExpression" ] in known_query_string_to_condition_map :
176
- # Turn the query into the resource-formatted query
177
- print (f"Converting { table_input ['KeyConditionExpression' ]} to { known_query_string_to_condition_map [table_input ['KeyConditionExpression' ]]} " )
178
- table_input ["KeyConditionExpression" ] = known_query_string_to_condition_map [table_input ["KeyConditionExpression" ]]
185
+ if table_input ["KeyConditionExpression" ] in known_key_condition_expression_string_to_condition_map :
186
+ table_input ["KeyConditionExpression" ] = known_key_condition_expression_string_to_condition_map [table_input ["KeyConditionExpression" ]]
187
+ else :
188
+ # Pass the original string through.
189
+ # The table will accept the string as-is.
190
+ pass
179
191
if "FilterExpression" in table_input :
180
- if table_input ["FilterExpression" ] in known_query_string_to_condition_map :
192
+ if table_input ["FilterExpression" ] in known_filter_expression_string_to_condition_map :
181
193
# Turn the query into the resource-formatted query
182
- print (f"Converting { table_input ['FilterExpression' ]} to { known_query_string_to_condition_map [table_input ['FilterExpression' ]]} " )
183
- table_input ["FilterExpression" ] = known_query_string_to_condition_map [table_input ["FilterExpression" ]]
194
+ table_input ["FilterExpression" ] = known_filter_expression_string_to_condition_map [table_input ["FilterExpression" ]]
195
+ else :
196
+ # Pass the original string through.
197
+ # The table will accept the string as-is.
198
+ pass
184
199
table_output = self ._table .query (** table_input )
185
200
client_output = self ._resource_shape_to_client_shape_converter .query_response (table_output )
186
201
return client_output
0 commit comments