File tree 1 file changed +7
-5
lines changed
1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 6
6
import json
7
7
import logging
8
8
import random
9
+ import re
9
10
import sys
10
11
import time
11
12
import uuid
@@ -1240,11 +1241,12 @@ def query(self,
1240
1241
# FilterExpression does not allow key attributes. Check for hash and range key name placeholders
1241
1242
hash_key_placeholder = name_placeholders .get (hash_keyname )
1242
1243
range_key_placeholder = range_keyname and name_placeholders .get (range_keyname )
1243
- if (
1244
- hash_key_placeholder in filter_expression or
1245
- (range_key_placeholder and range_key_placeholder in filter_expression )
1246
- ):
1247
- raise ValueError ("'filter_condition' cannot contain key attributes" )
1244
+ if re .search (hash_key_placeholder + r"\D" , filter_expression ):
1245
+ raise ValueError ("'filter_condition' cannot contain hash key. {} found in {}"
1246
+ .format (hash_key_placeholder , filter_expression ))
1247
+ if range_key_placeholder and re .search (range_key_placeholder + r"\D" , filter_expression ):
1248
+ raise ValueError ("'filter_condition' cannot contain range key. {} found in {}"
1249
+ .format (range_key_placeholder , filter_expression ))
1248
1250
operation_kwargs [FILTER_EXPRESSION ] = filter_expression
1249
1251
if attributes_to_get :
1250
1252
projection_expression = create_projection_expression (attributes_to_get , name_placeholders )
You can’t perform that action at this time.
0 commit comments