DynamoDB: allow leading underscore in expression attr name (#6082)
This commit is contained in:
parent
c4c5cdd3e7
commit
5eef06ee51
@ -116,8 +116,9 @@ class ExpressionTokenizer(object):
|
|||||||
An expression attribute name must begin with a pound sign (#), and be followed by one or more alphanumeric
|
An expression attribute name must begin with a pound sign (#), and be followed by one or more alphanumeric
|
||||||
characters.
|
characters.
|
||||||
"""
|
"""
|
||||||
return input_string.startswith("#") and cls.is_expression_attribute(
|
return (
|
||||||
input_string[1:]
|
input_string.startswith("#")
|
||||||
|
and re.compile("^[a-zA-Z0-9_]+$").match(input_string[1:]) is not None
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -182,8 +183,9 @@ class ExpressionTokenizer(object):
|
|||||||
|
|
||||||
def _make_list(self) -> List[Token]:
|
def _make_list(self) -> List[Token]:
|
||||||
"""
|
"""
|
||||||
Just go through characters if a character is not a token boundary stage it for adding it as a grouped token
|
Just go through characters
|
||||||
later if it is a tokenboundary process staged characters and then process the token boundary as well.
|
if a character is not a token boundary, stage it for adding it as a grouped token later
|
||||||
|
if it is a tokenboundary, process staged characters, and then process the token boundary as well.
|
||||||
"""
|
"""
|
||||||
for character in self.input_expression_str:
|
for character in self.input_expression_str:
|
||||||
if not self.is_possible_token_boundary(character):
|
if not self.is_possible_token_boundary(character):
|
||||||
|
@ -231,6 +231,18 @@ def test_expression_tokenizer_single_set_action_attribute_name_leading_number():
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_expression_tokenizer_single_set_action_attribute_name_leading_underscore():
|
||||||
|
set_action = "SET attr=#_sth"
|
||||||
|
token_list = ExpressionTokenizer.make_list(set_action)
|
||||||
|
assert token_list == [
|
||||||
|
Token(Token.ATTRIBUTE, "SET"),
|
||||||
|
Token(Token.WHITESPACE, " "),
|
||||||
|
Token(Token.ATTRIBUTE, "attr"),
|
||||||
|
Token(Token.EQUAL_SIGN, "="),
|
||||||
|
Token(Token.ATTRIBUTE_NAME, "#_sth"),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def test_expression_tokenizer_just_a_pipe():
|
def test_expression_tokenizer_just_a_pipe():
|
||||||
set_action = "|"
|
set_action = "|"
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user