diff --git a/cds/cdl.md b/cds/cdl.md index 7ecf16cc8..004dfef33 100644 --- a/cds/cdl.md +++ b/cds/cdl.md @@ -758,9 +758,8 @@ Their [`elements`](./csn#structured-types) signature is **inferred** from the pr Each element inherits all properties from the respective base element, except the `key` property. The `key` property is only inherited if all of the following applies: - No explicit `key` is set in the query. -- All key elements of the primary base entity are selected (for example, by using `*`). -- No path expression with a to-many association is used. -- No `union`, `join` or similar query construct is used. +- All key elements of the primary base entity and all key elements of + explicitly joined entities are selected. For example, the following definition: @@ -1424,10 +1423,6 @@ The rules are: 3. An explicit **cast** in the select clause cuts off the inheritance, for example, as for `genre` in our previous example. -::: tip -Propagation of annotations can be stopped via value `null`, for example, `@anno: null`. -::: - ### Expressions as Annotation Values @@ -1495,23 +1490,20 @@ actions { #### CSN Representation -In CSN, the expression is represented as a record with two properties: -* A string representation of the expression is stored in property `=`. -* A tokenized representation of the expression is stored in one of the properties - `xpr`, `ref`, `val`, `func`, etc. (like if the expression was written in a query). +In CSN, the expression is represented as a record with +one of the properties `xpr`, `ref`, `val`, `func`, etc., +that contains the tokenized representation of the expression +(like if the expression was written in a query). ```json { "@anExpression": { - "=": "foo.bar * 11", "xpr": [ {"ref": ["foo", "bar"]}, "*", {"value": 11} ] }, "@aRefExpr": { - "=": "foo.bar", "ref": ["foo", "bar"] }, "@aValueExpr": { - "=": "11", "val": 11 } } @@ -1520,13 +1512,17 @@ In CSN, the expression is represented as a record with two properties: Note the different CSN representations for a [plain value](#annotation-values) `"@anInteger": 11` and a value written as expression `@aValueExpr: ( 11 )`, respectively. +For expressions that are simple references, the record currently contains an additional +property `=` with the string representation of the expression. Do not rely on this property, +but use the tokenized representation. Property `=` may vanish in a future release. + + #### Propagation [Annotations are propagated](#annotation-propagation) in views/projections, via includes, and along type references. If the annotation value is an expression, it is sometimes necessary to adapt references inside the expression during propagation, for example, when a referenced element is renamed in a projection. -The compiler automatically takes care of the necessary rewriting. When a reference in an annotation expression -is rewritten, the `=` property is adapted accordingly if the expression is a single reference, otherwise it is set to `true`. +The compiler automatically takes care of the necessary rewriting. Example: ```cds @@ -1552,8 +1548,7 @@ rewritten to `@Common.Text: (descr)`. "elements": { // ... "code": { // original annotation - "@Common.Text": { "=": "text", - "ref": ["text"] }, + "@Common.Text": { "ref": ["text"] }, "type": "cds.Integer" }, "text": {"type": "cds.String"} @@ -1563,8 +1558,7 @@ rewritten to `@Common.Text: (descr)`. "elements": { // ... "code": { // propagated annotation, reference adapted - "@Common.Text": { "=": true, - "ref": ["descr"] }, + "@Common.Text": { "ref": ["descr"] }, "type": "cds.Integer" }, "descr": {"type": "cds.String"} @@ -1585,8 +1579,11 @@ In these cases you can overwrite the annotation with the correct expression in t Using an expression as annotation value only makes sense if the evaluator of the annotation is prepared to deal with the new CSN representation. -Currently, the CAP runtimes only support expressions in the `where` property of the `@restrict` annotation. +Currently, the CAP runtimes support expressions +* in the `where` property of annotation [`@restrict`](../guides/security/authorization#restrict-annotation) +* in annotation [`@assert`](../guides/services/constraints#assert-constraint) +Example: ```cds entity Orders @(restrict: [ { grant: 'READ', to: 'Auditor', where: (AuditBy = $user.id) } diff --git a/guides/databases/cdl-to-ddl.md b/guides/databases/cdl-to-ddl.md index 2c3f186e1..db3239c71 100644 --- a/guides/databases/cdl-to-ddl.md +++ b/guides/databases/cdl-to-ddl.md @@ -218,8 +218,8 @@ await cds.run `SELECT from sap_capire_bookshop_Books` | Int32 | INTEGER | INTEGER | INTEGER | INTEGER | | Int64 | BIGINT | BIGINT | BIGINT | BIGINT | | UInt8 | TINYINT | TINYINT | SMALLINT | SMALLINT | -| Decimal (p,s) | DECIMAL(p,s) | DECIMAL(p,s) | DECIMAL(p,s) | DECIMAL(p,s) | -| Decimal | DECIMAL | DECIMAL | DECFLOAT | DECIMAL | +| Decimal (p,s) | DECIMAL(p,s) | REAL_DECIMAL(p,s) | DECIMAL(p,s) | DECIMAL(p,s) | +| Decimal | DECIMAL | REAL_DECIMAL | DECFLOAT | DECIMAL | | Double | DOUBLE | DOUBLE | DOUBLE | FLOAT8 | | DateTime | SECONDDATE | DATETIME_TEXT | TIMESTAMP(0) | TIMESTAMP | | Date | DATE | DATE_TEXT | DATE | DATE |