Description
Using $self as the name of an entity, type, or aspect definition in CDL was deprecated and controlled by the name-deprecated-$self message. In CDS compiler v7 (CDS 10), this diagnostic is promoted to a non-configurable hard error. Any data model that defines an artifact with the name $self (e.g. entity $self { ... } or type $self) will fail to compile. Note that $self remains valid as a CQL reference in query expressions and association filters — only its use as a definition name is forbidden.
How to Check
- [ ] Run
cds compile— the compiler will emit an error for each definition named$self. - [ ] Search all
.cdsfiles for\$selfto find all occurrences. - [ ] For each match, distinguish between definition names (after
entity,type,aspect,servicekeywords) and CQL references (inwhere,on,filterclauses).
Migration Steps
Locate entity, type, or aspect definitions named
$self:cds// Breaking: $self used as a definition name entity $self { key ID : UUID; name : String; }Rename the artifact to a valid identifier and update all references:
diff- entity $self { + entity SelfRef { key ID : UUID; name : String; }Update all
annotate,extend, and service projection references to the new name:diff- annotate $self with @UI.LineItem: [...]; + annotate SelfRef with @UI.LineItem: [...]; service MyService { - entity Self as projection on db.$self; + entity Self as projection on db.SelfRef; }
Examples
$self as a definition name — breaking, must be renamed:
// Breaking: $self used as entity/aspect name
entity $self { // → rename to something valid
key ID : Integer;
}
aspect $self { // → rename
status : String;
}$self as a CQL reference in a where clause — valid, not affected:
// Not breaking: $self as a reference expression
entity BooksView as projection on Books {
*
} where $self.status = 'active'; // ← valid CQL, no change neededNotes
$self references in CQL expressions — such as where $self.status = 'active' in association on conditions or $self[predicate] filter expressions — are unaffected and remain valid in CDS 10. Only definition names are disallowed.