Skip to content

Commit

Permalink
Disambiguate constant expressions in CSDL JSON (#1987)
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikoTheissen authored Sep 11, 2024
1 parent b0a8935 commit 3cd7dc1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 15 deletions.
7 changes: 4 additions & 3 deletions docs/odata-csdl-json/odata-csdl-json.html
Original file line number Diff line number Diff line change
Expand Up @@ -2765,6 +2765,7 @@ <h3 id="1422-target"><a id="Target" href="#Target">14.2.2 Target</a></h3>
<h2 id="143-constant-expression"><a id="ConstantExpression" href="#ConstantExpression">14.3 Constant Expression</a></h2>
</summary>
<p>Constant expressions allow assigning a constant value to an applied term.</p>
<p>Primitive values of various types are represented as strings, therefore their type cannot be inferred from the constant expression alone. If such an ambiguous constant expression is an operand of a larger expression, clients MUST assume that the operand has the type demanded by the larger expression, for example, in a client-side function or in a comparison with another operand of known type. (In the <code>$Le</code> comparison in <a href="#disambiguate">example 75</a> <code>Duration</code> is of type <code>Edm.Duration</code>, therefore the constant expression <code>"PT1H"</code> is a duration, not a string.)</p>
<details open><summary>
<h3 id="1431-binary"><a id="Binary" href="#Binary">14.3.1 Binary</a></h3>
</summary>
Expand Down Expand Up @@ -3232,7 +3233,7 @@ <h3><a id="Eq.21.5" href="#Eq.21.5"><code>$Eq</code></a>, <a id="Ne.21.6" href="
<p>They MAY contain <a href="#Annotation">annotations</a>.</p>
</div>
<div class="varjson example">
<p>Example 75:</p>
<p>Example <a id="disambiguate" href="#disambiguate">75</a>:</p>
<div class="sourceCode" id="cb83"><pre class="sourceCode json"><code class="sourceCode json"><span id="cb83-1"><a href="#cb83-1" aria-hidden="true" tabindex="-1"></a><span class="fu">{</span></span>
<span id="cb83-2"><a href="#cb83-2" aria-hidden="true" tabindex="-1"></a> <span class="dt">&quot;$And&quot;</span><span class="fu">:</span> <span class="ot">[</span></span>
<span id="cb83-3"><a href="#cb83-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">{</span></span>
Expand Down Expand Up @@ -3301,9 +3302,9 @@ <h3><a id="Eq.21.5" href="#Eq.21.5"><code>$Eq</code></a>, <a id="Ne.21.6" href="
<span id="cb83-66"><a href="#cb83-66" aria-hidden="true" tabindex="-1"></a><span class="fu">{</span></span>
<span id="cb83-67"><a href="#cb83-67" aria-hidden="true" tabindex="-1"></a> <span class="dt">&quot;$Le&quot;</span><span class="fu">:</span> <span class="ot">[</span></span>
<span id="cb83-68"><a href="#cb83-68" aria-hidden="true" tabindex="-1"></a> <span class="fu">{</span></span>
<span id="cb83-69"><a href="#cb83-69" aria-hidden="true" tabindex="-1"></a> <span class="dt">&quot;$Path&quot;</span><span class="fu">:</span> <span class="st">&quot;Price&quot;</span></span>
<span id="cb83-69"><a href="#cb83-69" aria-hidden="true" tabindex="-1"></a> <span class="dt">&quot;$Path&quot;</span><span class="fu">:</span> <span class="st">&quot;Duration&quot;</span></span>
<span id="cb83-70"><a href="#cb83-70" aria-hidden="true" tabindex="-1"></a> <span class="fu">}</span><span class="ot">,</span></span>
<span id="cb83-71"><a href="#cb83-71" aria-hidden="true" tabindex="-1"></a> <span class="dv">100</span></span>
<span id="cb83-71"><a href="#cb83-71" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;PT1H&quot;</span></span>
<span id="cb83-72"><a href="#cb83-72" aria-hidden="true" tabindex="-1"></a> <span class="ot">]</span></span>
<span id="cb83-73"><a href="#cb83-73" aria-hidden="true" tabindex="-1"></a><span class="fu">}</span><span class="er">,</span></span>
<span id="cb83-74"><a href="#cb83-74" aria-hidden="true" tabindex="-1"></a><span class="fu">{</span></span>
Expand Down
14 changes: 11 additions & 3 deletions docs/odata-csdl-json/odata-csdl-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -3928,6 +3928,14 @@ properties targeted via the declaring structured type.
Constant expressions allow assigning a constant value to an applied
term.

Primitive values of various types are represented as strings, therefore their type
cannot be inferred from the constant expression alone. If such
an ambiguous constant expression is an operand of a larger expression, clients MUST assume
that the operand has the type demanded by the larger expression, for example, in a
client-side function or in a comparison with another operand of known type.
(In the `$Le` comparison in [example 75](#disambiguate) `Duration` is of type
`Edm.Duration`, therefore the constant expression `"PT1H"` is a duration, not a string.)

### <a id="Binary" href="#Binary">14.3.1 Binary</a>

::: {.varjson .rep}
Expand Down Expand Up @@ -4779,7 +4787,7 @@ They MAY contain [annotations](#Annotation).
:::

::: {.varjson .example}
Example 75:
Example <a id="disambiguate" href="#disambiguate">75</a>:
```json
{
"$And": [
Expand Down Expand Up @@ -4849,9 +4857,9 @@ Example 75:
{
"$Le": [
{
"$Path": "Price"
"$Path": "Duration"
},
100
"PT1H"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions docs/odata-csdl-xml/odata-csdl-xml.html
Original file line number Diff line number Diff line change
Expand Up @@ -3161,8 +3161,8 @@ <h3><a id="ExpressionsedmEq.51" href="#ExpressionsedmEq.51">Expressions <code>ed
<span id="cb80-30"><a href="#cb80-30" aria-hidden="true" tabindex="-1"></a> &lt;<span class="kw">Int</span>&gt;20&lt;/<span class="kw">Int</span>&gt;</span>
<span id="cb80-31"><a href="#cb80-31" aria-hidden="true" tabindex="-1"></a>&lt;/<span class="kw">Lt</span>&gt;</span>
<span id="cb80-32"><a href="#cb80-32" aria-hidden="true" tabindex="-1"></a>&lt;<span class="kw">Le</span>&gt;</span>
<span id="cb80-33"><a href="#cb80-33" aria-hidden="true" tabindex="-1"></a> &lt;<span class="kw">Path</span>&gt;Price&lt;/<span class="kw">Path</span>&gt;</span>
<span id="cb80-34"><a href="#cb80-34" aria-hidden="true" tabindex="-1"></a> &lt;<span class="kw">Int</span>&gt;100&lt;/<span class="kw">Int</span>&gt;</span>
<span id="cb80-33"><a href="#cb80-33" aria-hidden="true" tabindex="-1"></a> &lt;<span class="kw">Path</span>&gt;Duration&lt;/<span class="kw">Path</span>&gt;</span>
<span id="cb80-34"><a href="#cb80-34" aria-hidden="true" tabindex="-1"></a> &lt;<span class="kw">Duration</span>&gt;PT1H&lt;/<span class="kw">Duration</span>&gt;</span>
<span id="cb80-35"><a href="#cb80-35" aria-hidden="true" tabindex="-1"></a>&lt;/<span class="kw">Le</span>&gt;</span>
<span id="cb80-36"><a href="#cb80-36" aria-hidden="true" tabindex="-1"></a>&lt;<span class="kw">Has</span>&gt;</span>
<span id="cb80-37"><a href="#cb80-37" aria-hidden="true" tabindex="-1"></a> &lt;<span class="kw">Path</span>&gt;Fabric&lt;/<span class="kw">Path</span>&gt;</span>
Expand Down
5 changes: 3 additions & 2 deletions docs/odata-csdl-xml/odata-csdl-xml.md
Original file line number Diff line number Diff line change
Expand Up @@ -3737,6 +3737,7 @@ properties targeted via the declaring structured type.
Constant expressions allow assigning a constant value to an applied
term.


### <a id="Binary" href="#Binary">14.3.1 Binary</a>


Expand Down Expand Up @@ -4757,8 +4758,8 @@ Example 75:
<Int>20</Int>
</Lt>
<Le>
<Path>Price</Path>
<Int>100</Int>
<Path>Duration</Path>
<Duration>PT1H</Duration>
</Le>
<Has>
<Path>Fabric</Path>
Expand Down
20 changes: 15 additions & 5 deletions odata-csdl/14 Vocabulary and Annotation.md
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,16 @@ properties targeted via the declaring structured type.
Constant expressions allow assigning a constant value to an applied
term.

: varjson
Primitive values of various types are represented as strings, therefore their type
cannot be inferred from the constant expression alone. If such
an ambiguous constant expression is an operand of a larger expression, clients MUST assume
that the operand has the type demanded by the larger expression, for example, in a
client-side function or in a comparison with another operand of known type.
(In the `$Le` comparison in [example ##disambiguate] `Duration` is of type
`Edm.Duration`, therefore the constant expression `"PT1H"` is a duration, not a string.)
:

### ##subsubsec Binary

::: {.varjson .rep}
Expand Down Expand Up @@ -2012,7 +2022,7 @@ They MAY contain [annotations](#Annotation).
:::

::: {.varjson .example}
Example ##ex:
Example ##ex_disambiguate:
```json
{
"$And": [
Expand Down Expand Up @@ -2082,9 +2092,9 @@ Example ##ex:
{
"$Le": [
{
"$Path": "Price"
"$Path": "Duration"
},
100
"PT1H"
]
},
{
Expand Down Expand Up @@ -2175,8 +2185,8 @@ Example ##ex:
<Int>20</Int>
</Lt>
<Le>
<Path>Price</Path>
<Int>100</Int>
<Path>Duration</Path>
<Duration>PT1H</Duration>
</Le>
<Has>
<Path>Fabric</Path>
Expand Down

0 comments on commit 3cd7dc1

Please sign in to comment.