no-join-on-draft
Rule Details
Draft-enabled entities shall not be used in views that make use of JOIN
. This rule will report a warning for any violations.
Examples
✅ Correct example
In the following example, no draft-enabled entities are used in the service CatalogService
:
cds
using { sap.capire.bookshop as my } from '../db/schema';
service CatalogService {
@readonly entity ListOfBooks as projection on Books
excluding { descr };
@readonly entity Books as projection on my.Books { *,
author.name as author
} excluding { createdBy, modifiedBy }
actions {
@requires: 'Admin'
action addRating (stars: Integer);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
❌ Incorrect example
In the next example, the service CatalogService
uses a draft-enabled entity and makes use of JOIN
, which violates the rule:
cds
using { sap.capire.bookshop as my } from '../db/schema';
service CatalogService {
@readonly entity ListOfBooks as projection on Books
excluding { descr };
@odata.draft.enabled
@readonly entity Books as projection on my.Books { *,
author.name as author
} excluding { createdBy, modifiedBy }
actions {
@requires: 'Admin'
action addRating (stars: Integer);
}
// Do not use draft-enabled entities in views that make use of `JOIN`.
entity BooksFromList as select Books.ID from Books CROSS JOIN ListOfBooks;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Version
This rule was introduced in @sap/eslint-plugin-cds 2.2.1
.