Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Non-ID" keys #117

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

"Non-ID" keys #117

wants to merge 15 commits into from

Conversation

nils
Copy link

@nils nils commented Sep 17, 2024

In our project, we are dealing with a legacy data model that does not follow the best practices regarding primary keys, and there is nothing we can change about it in the mid term.

This PR aims at introducing the capability to deal with change logs for entities with complex/composite keys.

It does not cover all scenarios, but at least some situations.

@nils nils mentioned this pull request Sep 17, 2024

for (let idx = 0; idx < paths.length; idx++) {
const entity = getEntityByContextPath(paths.slice(0, idx + 1), txContext.hasComp)
const entityID = entityIDs[idx]
const entityPathVal = `${entity.name}(${entityID})`
const entityPathVal = {target: entity.name, key: entityID};
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This illustrates one main change: paths are expressed as JSON arrays like

[{target: "RootEntity", key: {ID: "..."}}, {target: "Level1Entity", key: {ID: "..."}}]

instead of

"RootEntity(...)/Level1Entity(...)"

serviceEntity: target.name || target,
changes: changes.filter(c => c.valueChangedFrom || c.valueChangedTo).map((c) => ({
...c,
serviceEntityPath: stringifyPath(c.serviceEntityPath),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, if there is a single-key situation, we now serialize paths to the 'old' format before saving to the db.

@nkaputnik
Copy link
Contributor

@Sv7enNowitzki can you please have a look at the tests and give an OK to merge this into the main branch?

@Sv7enNowitzki
Copy link
Collaborator

@Sv7enNowitzki can you please have a look at the tests and give an OK to merge this into the main branch?

Hi @nkaputnik

No, as I mentioned earlier in the email, the current code does not work in a CAP application, such as simple-bookshop.

Best Regards,
Wenjun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants