Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DynamoDb2 ExpressionAttributeNames can start with a number #3206

Merged
merged 1 commit into from
Jul 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion moto/dynamodb2/parsing/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def is_possible_token_boundary(cls, character):

@classmethod
def is_expression_attribute(cls, input_string):
return re.compile("^[a-zA-Z][a-zA-Z0-9_]*$").match(input_string) is not None
return re.compile("^[a-zA-Z0-9][a-zA-Z0-9_]*$").match(input_string) is not None

@classmethod
def is_expression_attribute_name(cls, input_string):
Expand Down
12 changes: 12 additions & 0 deletions tests/test_dynamodb2/test_dynamodb_expression_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,18 @@ def test_expression_tokenizer_single_set_action_attribute_name_valid_key():
]


def test_expression_tokenizer_single_set_action_attribute_name_leading_number():
set_action = "SET attr=#0"
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, "#0"),
]


def test_expression_tokenizer_just_a_pipe():
set_action = "|"
try:
Expand Down