Skip to content

Commit 07630a9

Browse files
committed
more improvements to section on path expressions
1 parent 7c5c0a3 commit 07630a9

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

spec/src/main/asciidoc/chapters/language/expressions.adoc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ Any other sort of path expression might begin with:
100100

101101
The first element of the path expression is called the _root element_ of the path.
102102

103-
A path expression is always a compound path identifying an element of a structure, as discussed above in <<paths>>. Each identifier -- except, possibly, for the first identifier in the list -- is interpreted as the label of an element of an entity or embeddable type.
103+
A path expression is a compound path identifying a labelled element of a structure, as discussed above in <<paths>>. Every prefix of a path is itself a path. That is, _every_ identifier in a path is interpreted as the label of an element of a structure.
104104

105105
Each element of the path is assigned a type:
106106

107-
1. If the root element is an identifier matching an alias declared in the `from` clause, as defined below in <<from-clause>>, the root element is assigned the entity type associated with that alias.footnote:[This is the same type as the type of a structure with that label belonging to each element of the result list.]
108-
2. Otherwise, if the root element is an identifier, and if the `from` clause declares a root entity with (implicit or explicit) alias `this`, then the path expression is interpreted as if it were prefixed with the first element `this`, with `this` being assigned the type of the root entity.footnote:[This is the same type as the type of a structure with label `this` belonging to each element of the result list.]
107+
1. If the root element is an identifier matching an alias declared in a `from` clause of any containing query, as defined below in <<from-clause>>, the root element is assigned the entity type associated with that alias.footnote:[This is the same type as the type of a structure with that label belonging to each element of the result list.]
108+
2. Otherwise, if the root element is an identifier, and if a containing query has a `from` clause declaring a root entity with (implicit or explicit) alias `this`, then the path expression is interpreted as if it were prefixed with the first element `this`, with `this` being assigned the type of the root entity.footnote:[This is the same type as the type of a structure with label `this` belonging to each element of the result list.]
109109
3. If the root element is a `#treated_entity_path_expression#`, then it is assigned the treated type, according to the usual rules defined by <<treat>>.
110110
4. If the root element is a map key or value expression, then it is assigned a type according to the usual rules specified by <<map-key-value>>.
111111
5. The identifier of each non-root element must match the label of an element of the entity or embeddable type assigned to the previous element. Then the non-root element is assigned the type of this element of the entity or embeddable type.
@@ -116,8 +116,11 @@ NOTE: Typically, the last element of a path expression is assigned an <<atomic-v
116116

117117
When a path expression is executed, each element of the path is evaluated in turn:
118118

119-
- the root element of the path expression is evaluated in the context of a given structure belonging to a result list, and, if it is an identifier, evaluates to the value of the labeled element of the given structure, and then
120-
- each subsequent element is evaluated in the context of the result structure produced by the previous element (typically, an embeddable class or associated entity class), and evaluates to the value of the labeled element of the result structure.
119+
- The root element of the path expression is evaluated in the context of a given structure belonging to a result list, and:
120+
* if the root element is an identifier, it evaluates to the value of the labeled element of the given structure, or
121+
* otherwise, it is evaluated as a value expression according to the rules specified here.
122+
123+
- Each subsequent element of the path is evaluated in the context of the structure produced by evaluating the previous element (typically, an instance of an entity or embeddable type), and evaluates to the value of the labeled element of the result structure.
121124

122125
If any element of a path expression evaluates to a null value, the whole path expression evaluates to a null value.
123126

0 commit comments

Comments
 (0)