Description
In CDL, inline and expand operators use the { } syntax to nest sub-elements in a select clause. In CDS compiler v7 (CDS 10), using these operators in SQL-style as select view definitions (in the part before the from keyword) is a hard error. The inline and expand operators remain valid in CQL projection-style views (as projection on) and in query builder code. SQL-style views that use { } before from must be rewritten either as projection-style views or by flattening the nested element access.
How to Check
- [ ] Run
cds compile— the compiler emits a hard error for each affected SQL-style view. - [ ] Search all
.cdsfiles foras selectto find SQL-style view definitions. - [ ] For each match, inspect the select clause for
{before thefromkeyword — indicating inline or expand usage.
Migration Steps
Locate a SQL-style view using inline or expand in the select list:
cds// Breaking: inline operator in SQL-style select entity BookDetails as select from Books { ID, author { name, bio }, title };Convert to a projection-style view, which fully supports inline/expand:
diff- entity BookDetails as select from Books { - ID, - author { name, bio }, - title - }; + entity BookDetails as projection on Books { + ID, + author { name, bio }, + title + };If the SQL-style select is needed for its filtering or join capabilities, flatten the inline expression by using explicit path references instead:
diff- entity BookDetails as select from Books { - ID, - author { name } - } where stock > 0; + entity BookDetails as select from Books + left join Authors on Books.author_ID = Authors.ID + { + Books.ID, + Authors.name as authorName + } where Books.stock > 0;
Examples
SQL-style select with inline operator — breaking:
// Breaking: inline/expand used in SQL-style select (before FROM)
entity BooksWithAuthor as select from Books {
ID, title,
author { name, dateOfBirth } // ← inline operator before FROM: error
};CQL-style projection with inline operator — valid, no change needed:
// Valid: inline operator after FROM in CQL-style
entity BooksWithAuthor as projection on Books {
ID, title,
author { name, dateOfBirth } // ← same operator, CQL-style: fine
};To migrate, change as select from to as projection on:
- entity BooksWithAuthor as select from Books {
+ entity BooksWithAuthor as projection on Books {
ID, title,
author { name, dateOfBirth }
};Notes
Projection-style views (as projection on) should be preferred over SQL-style views (as select from) in CDL when inline/expand operators are needed. SQL-style views are intended for cases requiring explicit joins, grouping, or subqueries that projection syntax cannot express. For views that only add nesting to a single base entity, switching to as projection on is a straightforward migration with no semantic change.