Skip to content

Commit 2c42b72

Browse files
qmacrodanjoa
andauthored
Replace 'entity' identifier example from cdl.md (#1982)
In the "Keywords & Identifiers" section there's an example of the keyword `entity` being used as an identifier, which seems confusing and "asking for trouble" :-) Moreover, a little further on, in a "Warning" section, it states "Delimited identifiers in general, but in particular non-ASCII characters, _or keywords as identifiers_ should be avoided as much as possible, for reasons of interoperability." (emphasis mine). In addition, the definition of the `entity` aspect also had an `Integer` key called `ID`, which is perhaps not to be universally encouraged (better to use `cuid` with its `UUID` type). So I reworked this section. Co-authored-by: Daniel Hutzel <[email protected]>
1 parent cdf69ad commit 2c42b72

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

cds/cdl.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,19 @@ The *Conceptual Definition Language (CDL)* is a human-readable language for defi
4141

4242
```cds
4343
namespace capire.bookshop;
44-
using { managed } from `@sap/cds/common`;
45-
aspect entity : managed { key ID: Integer }
44+
using { managed, cuid } from `@sap/cds/common`;
45+
aspect primary : managed, cuid {}
4646
47-
entity Books : entity {
47+
entity Books : primary {
4848
title : String;
4949
author : Association to Authors;
5050
}
5151
52-
entity Authors : entity {
52+
entity Authors : primary {
5353
name : String;
5454
}
5555
```
5656

57-
::: details Noteworthy...
58-
In the example above `entity` shows up as a keyword, as well as an identifier of an aspect declaration and references to that.
59-
:::
60-
6157
Keywords are *case-insensitive*, but are most commonly used in lowercase notation.
6258

6359
Identifiers are *case-significant*, that is, `Foo` and `foo` would identify different things.
@@ -69,7 +65,7 @@ type ![Delimited Identifier] : String;
6965
```
7066

7167
::: warning Avoid using delimited identifiers
72-
Delimited identifiers in general, but in particular non-ASCII characters, or keywords as identifiers should be avoided as much as possible, for reasons of interoperability.
68+
Delimited identifiers in general, but in particular non-ASCII characters, should be avoided as much as possible, for reasons of interoperability.
7369
:::
7470

7571

0 commit comments

Comments
 (0)