Skip to content

Commit

Permalink
fix: do not try to change track personal data
Browse files Browse the repository at this point in the history
fix #97
  • Loading branch information
patricebender committed Jun 19, 2024
1 parent 1581c92 commit 9b7278d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
4 changes: 3 additions & 1 deletion lib/template-processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const _processElement = (processFn, row, key, elements, isRoot, pathSegments, pi
const element = elements[key];
const { plain } = picked;

if (plain) {
// do not change-track personal data
const isPersonalData = element && Object.keys(element).some(key => key.startsWith('@PersonalData'));
if (plain && !isPersonalData) {
/**
* @type import('../../types/api').templateProcessorProcessFnArgs
*/
Expand Down
7 changes: 7 additions & 0 deletions tests/bookshop/db/schema.cds
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,13 @@ entity Customers : cuid {
on orderItems.customer = $self;
}

// do not change-track personal data
annotate Customers with {
name @PersonalData.IsPotentiallyPersonal;
name @changelog
};


entity OrderHeader : cuid {
status : String;
}
Expand Down
19 changes: 6 additions & 13 deletions tests/integration/service-api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,23 +303,16 @@ describe("change log integration test", () => {
cds.services.AdminService.entities.BookStoreRegistry["@changelog"] = [{ "=": "code" }];
});

it("10.9 Child entity deep delete by QL API - should log changes on root entity (ERP4SMEPREPWORKAPPPLAT-3063)", async () => {
await UPDATE(adminService.entities.BookStores).where({ ID: "64625905-c234-4d0d-9bc1-283ee8946770" }).with({
registry: null,
registry_ID: null,
it("Do not change track personal data", async () => {
const allCustomers = await SELECT.from(adminService.entities.Customers);
await UPDATE(adminService.entities.Customers).where({ ID: allCustomers[0].ID }).with({
name: 'John Doe',
});

const changes = await SELECT.from(ChangeView).where({
entity: "sap.capire.bookshop.BookStoreRegistry",
attribute: "validOn",
entity: "sap.capire.bookshop.Customers",
});

expect(changes.length).to.equal(1);
expect(changes[0].entityKey).to.equal("64625905-c234-4d0d-9bc1-283ee8946770");
expect(changes[0].objectID).to.equal("Paris-1");
expect(changes[0].modification).to.equal("delete");
expect(changes[0].parentObjectID).to.equal("Shakespeare and Company");
expect(changes[0].valueChangedFrom).to.equal("2012-01-01");
expect(changes[0].valueChangedTo).to.equal("");
expect(changes.length).to.equal(0);
});
});

0 comments on commit 9b7278d

Please sign in to comment.