Skip to content

Commit fd82946

Browse files
authored
fix: draft enabled & composite keys (#37)
* do not search by isactiveentity * rm localization from data model * fix: draft enabled entities * test: composite keys entity * tests: refactor and add new ones
1 parent 3aa83e3 commit fd82946

File tree

12 files changed

+315
-191
lines changed

12 files changed

+315
-191
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
}
6969
},
7070
"scripts": {
71-
"test": "npx jest",
71+
"test": "npx jest --silent",
7272
"lint": "npx eslint --fix . --no-cache",
7373
"in-cap-dev": "cd node_modules && rm -fr @sap/cds* @cap-js/db-service @cap-js/sqlite",
7474
"prettier": "npx -y prettier@3 --write .",

srv/service.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class PrintService extends cds.Service {
3131

3232
for (let i = 0; i < keyFields.length; i++) {
3333
const keyField = keyFields[i];
34+
if (keyField === "IsActiveEntity") continue; // select with IsActiveEntity is not supported
3435
const keyFilterIndex = req.query?.SELECT?.where?.findIndex(
3536
(item) =>
3637
typeof item === "object" &&
@@ -42,7 +43,7 @@ class PrintService extends cds.Service {
4243
keys[keyField] = keyValue;
4344

4445
if (req.query?.SELECT?.where && req.query.SELECT.where.length === 3) {
45-
delete req.query.SELECT.where;
46+
req.query.SELECT.where = undefined;
4647
} else {
4748
req.query.SELECT.where.splice(keyFilterIndex, 4);
4849
}

test/bookshop/db/data/sap.capire.bookshop-Books_texts.csv

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/bookshop/db/data/sap.capire.bookshop-Bookss.csv

Lines changed: 0 additions & 6 deletions
This file was deleted.

test/bookshop/db/init.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,17 @@ module.exports = async function () {
9595
}),
9696
];
9797
});
98+
99+
insertPromises.push(
100+
INSERT.into("CompositeKeys").entries({
101+
ID: 1,
102+
ID2: 2,
103+
file: templatePDF,
104+
fileName: `Book_Composite_Summary.pdf`,
105+
file2: templatePDF,
106+
fileName2: `Book_Composite_Summary_2.pdf`,
107+
}),
108+
);
109+
98110
await Promise.all(insertPromises);
99111
};

test/bookshop/db/schema.cds

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ entity Books : managed, BooksWithOneFile {
1414

1515
entity BooksWithOneFile {
1616
key ID : Integer;
17-
title : localized String(111) @mandatory;
18-
descr : localized String(1111);
17+
title : String(111) @mandatory;
18+
descr : String(1111);
1919
author : Association to Authors @mandatory;
2020
genre : Association to Genres;
2121
stock : Integer;
@@ -48,3 +48,21 @@ entity Genres : sap.common.CodeList {
4848
children : Composition of many Genres
4949
on children.parent = $self;
5050
}
51+
52+
entity CompositeKeys : managed {
53+
key ID : Integer;
54+
key ID2 : Integer;
55+
56+
@Common.Label: '{i18n>Summary}'
57+
@Core.MediaType: 'application/pdf'
58+
@Core.ContentDisposition: fileName
59+
file : LargeBinary;
60+
@Common.Label: '{i18n>Summary}'
61+
fileName : String @readonly;
62+
@Common.Label: '{i18n>Summary2} '
63+
@Core.MediaType: 'application/pdf'
64+
@Core.ContentDisposition: fileName2
65+
file2 : LargeBinary ;
66+
@Common.Label: '{i18n>Summary2} '
67+
fileName2 : String @readonly;
68+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using {sap.capire.bookshop as my} from '../db/schema';
22

33
service AdminService @(requires: 'admin') {
4+
@PDF.Printable
45
entity Books as projection on my.Books;
56
entity Authors as projection on my.Authors;
67
}

test/bookshop/srv/cat-service.cds

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,8 @@ service CatalogService {
6868
quantity : Integer;
6969
buyer : String
7070
};
71+
72+
@odata.draft.enabled
73+
@PDF.Printable
74+
entity CompositeKeys as projection on my.CompositeKeys;
7175
}

test/integration/entities.test.js

Lines changed: 0 additions & 176 deletions
This file was deleted.

0 commit comments

Comments
 (0)