2828# 4f18689f79243c9a5ab0f3a23108671defddeac4
2929# If any query strings are added to TestVectors, they COULD be added here;
3030# 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 = {
3232 # "Basic" queries
3333 "RecNum = :zero" : Attr ("RecNum" ).eq (":zero" ),
34- "RecNum = :one" : Attr ("RecNum" ).eq (":one" ),
3534 "RecNum <= :zero" : Attr ("RecNum" ).lte (":zero" ),
3635 "RecNum > :zero" : Attr ("RecNum" ).gt (":zero" ),
3736 "RecNum >= :zero" : Attr ("RecNum" ).gte (":zero" ),
8786 ":cmp1c <= Comp1" : ":cmp1c <= Comp1" ,
8887}
8988
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+
9095class DynamoDBClientWrapperForDynamoDBTable :
9196 """
9297 DBESDK TestVectors-internal wrapper class.
@@ -147,15 +152,20 @@ def scan(self, **kwargs):
147152 # convert the string-based KeyConditionExpression and FilterExpression
148153 # into the boto3.conditions.Key and boto3.conditions.Attr resource-formatted queries.
149154 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
154161 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 :
156163 # 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
159169 table_output = self ._table .scan (** table_input )
160170 client_output = self ._resource_shape_to_client_shape_converter .scan_response (table_output )
161171 return client_output
@@ -172,15 +182,20 @@ def query(self, **kwargs):
172182 # convert the string-based KeyConditionExpression and FilterExpression
173183 # into the boto3.conditions.Key and boto3.conditions.Attr resource-formatted queries.
174184 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
179191 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 :
181193 # 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
184199 table_output = self ._table .query (** table_input )
185200 client_output = self ._resource_shape_to_client_shape_converter .query_response (table_output )
186201 return client_output
0 commit comments