You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/refguide/modeling/domain-model/oql/oql-expression-syntax.md
+19-9Lines changed: 19 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -625,7 +625,7 @@ FROM Sales.Order
625
625
| Doe | 2 | 5.0 | Regular |
626
626
| Moose | 3 | 8.2 | Priority |
627
627
628
-
If result expressions have different numeric types, date type of the result expression in the first WHEN has priority, and the whole CASE expression has type of that result expression. This behavior matches the behavior of supported database vendors.
628
+
If result expressions have different numeric types, data type of the result expression is defined based on [type coercion precedence](#type-coercion).
In OQL v1, the expression gets the type of the first argument. If you use OQL v1, the type of `NumberOrPrice` in the example above is Integer, not Decimal.
654
+
{{% /alert %}}
651
655
652
656
### Operator Precedence
653
657
@@ -796,7 +800,7 @@ SELECT COALESCE(LastName, FirstName) AS Name FROM Sales.Customer
796
800
| Doe |
797
801
| Jane |
798
802
799
-
If arguments of `COALESCE` have different numeric types, the expression gets the type of the first argument. This behavior matches the behavior of supported database vendors.
803
+
If arguments of `COALESCE` have different numeric types, the result type of the operation depends on OQL version. Consider the following query:
In OQL v1, the expression gets the type of the first argument. If you use OQL v1, the type of `AgeOrAmount` in the example above is Integer, not Decimal.
Copy file name to clipboardExpand all lines: content/en/docs/refguide/modeling/domain-model/oql/oql-v2.md
+5-9Lines changed: 5 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@ In OQL v2, all result expressions of a [CASE](/refguide/oql-expression-syntax/#c
48
48
49
49
Also, in OQL v2 it is no longer possible to have Null as the result of all result expressions of CASE. In OQL v1, that was allowed, but would lead to database-level exceptions for some database vendors.
50
50
51
-
Numeric types Integer, Long and Decimal are considered matching. See [examples](/refguide/oql-expression-syntax/#case-expression-examples)of `CASE` expressions for details on how different numeric types are combined.
51
+
Numeric types Integer, Long and Decimal are considered matching. The type of the resulting expression is defined according to [type coercion precedence](/refguide/oql-expression-syntax/#type-coercion). In OQL v1, the type of the expression was defined based on the first result expression of `CASE`.
52
52
53
53
#### `COALESCE` {#coalesce-validations}
54
54
@@ -58,7 +58,7 @@ In OQL v2, all arguments of a [COALESCE](/refguide/oql-expression-syntax/#coales
58
58
59
59
Also, in OQL v2 it is no longer possible to have a COALESCE expression where all arguments are Null literals. In OQL v1, that was allowed, but would lead to database-level exceptions for some database vendors.
60
60
61
-
Numeric types Integer, Long and Decimal are considered matching. See [examples](/refguide/oql-expression-syntax/#coalesce-expression-examples)of `COALESCE` for details on how different numeric types are combined.
61
+
Numeric types Integer, Long and Decimal are considered matching. The type of the resulting expression is defined according to [type coercion precedence](/refguide/oql-expression-syntax/#type-coercion). In OQL v1, the type of the expression was defined based on the first argument of `COALESCE`.
62
62
63
63
#### `LENGTH` {#length-validations}
64
64
@@ -229,15 +229,11 @@ SELECT Attribute1 + Attribute2 AS SumAttr
229
229
FROMModule.Entity
230
230
```
231
231
232
-
In OQL v1, the result of the arithmetic operation will always be of type pf the first attribute in the expression because it is handled by the database. Therefore, the result would depend on the underlying database engine.
232
+
In OQL v1, the result of the arithmetic operation will always be of type of the first attribute in the expression. Therefore, the result would depend on the underlying database engine.
233
233
234
-
When handling numeric types in OQL v2 (Integer, Long, and Decimal), the result of the operation is always the most precise attribute type, using the following precedence:
234
+
When handling numeric types in OQL v2 (Integer, Long, and Decimal), the result type is defined according to [type coercion precedence](/refguide/oql-expression-syntax/#type-coercion).
235
235
236
-
* Decimal (highest)
237
-
* Long
238
-
* Integer
239
-
240
-
If any side of the operation is of a non-numeric type, no casting is performed, and the result is handled by the database, as in OQL v1. See [Expression syntax](/refguide/oql-expression-syntax/#type-coercion) for more information.
236
+
If any side of the operation is of a non-numeric type, no casting is performed, and the result is handled by the database, as in OQL v1.
0 commit comments