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

Disambiguate constant expressions in CSDL JSON #1987

Merged
merged 4 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
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 @@ -2763,6 +2763,7 @@ <h3 id="1422-target"><a name="Target" href="#Target">14.2.2 Target</a></h3>
<h2 id="143-constant-expression"><a name="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 name="Binary" href="#Binary">14.3.1 Binary</a></h3>
</summary>
Expand Down Expand Up @@ -3230,7 +3231,7 @@ <h3 id="eq-ne-gt-ge-lt-le-has-and-in"><a name="Eq.21.5" href="#Eq.21.5"><code>$E
<p>They MAY contain <a href="#Annotation">annotations</a>.</p>
</div>
<div class="varjson example">
<p>Example 75:</p>
<p>Example <a name="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 @@ -3299,9 +3300,9 @@ <h3 id="eq-ne-gt-ge-lt-le-has-and-in"><a name="Eq.21.5" href="#Eq.21.5"><code>$E
<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 name="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 name="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 @@ -3159,8 +3159,8 @@ <h3 id="expressions-edmeq-edmne-edmgt-edmge-edmlt-edmle-edmhas-and-edmin"><a nam
<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 name="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