moto/moto/dynamodb2/parsing
Thomas Ross 67ae84e2c4
Only raise EmptyKeyAttributeException when the value node is empty (#4014)
This fixes a bug where all updates to keys (including GSIs) would raise
EmptyKeyAttributeException, even when the new value was not an empty string.
2021-06-17 12:19:47 +01:00
..
__init__.py Better DDB expressions support1: TokenizationDDB 2020-04-18 09:16:23 +01:00
ast_nodes.py Improve DDB expressions support3: AST Validation 2020-04-19 16:58:07 +01:00
executors.py dynamodb: fix deleting last set element (w/attr name) (#3708) 2021-02-19 07:47:51 +00:00
expressions.py Improve DDB expressions support3: AST Validation 2020-04-19 16:58:07 +01:00
README.md Improve DDB expressions support3: AST Validation 2020-04-19 16:58:07 +01:00
reserved_keywords.py Better DDB expressions support2: ExpressionTree 2020-04-18 09:19:03 +01:00
reserved_keywords.txt Better DDB expressions support2: ExpressionTree 2020-04-18 09:19:03 +01:00
tokens.py Fix DynamoDb2 ExpressionAttributeNames can start with a number (#3206) 2020-07-31 17:46:48 +01:00
validators.py Only raise EmptyKeyAttributeException when the value node is empty (#4014) 2021-06-17 12:19:47 +01:00

Parsing dev documentation

Parsing happens in a structured manner and happens in different phases. This document explains these phases.

1) Expression gets parsed into a tokenlist (tokenized)

A string gets parsed from left to right and gets converted into a list of tokens. The tokens are available in tokens.py.

2) Tokenlist get transformed to expression tree (AST)

This is the parsing of the token list. This parsing will result in an Abstract Syntax Tree (AST). The different node types are available in ast_nodes.py. The AST is a representation that has all the information that is in the expression but its tree form allows processing it in a structured manner.

3) The AST gets validated (full semantic correctness)

The AST is used for validation. The paths and attributes are validated to be correct. At the end of the validation all the values will be resolved.

4) Update Expression gets executed using the validated AST

Finally the AST is used to execute the update expression. There should be no reason for this step to fail since validation has completed. Due to this we have the update expressions behaving atomically (i.e. all the actions of the update expresion are performed or none of them are performed).