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

feat: m2m change detection follow up #1046

Merged
merged 10 commits into from May 19, 2024

Conversation

Grandlouis
Copy link
Collaborator

@Grandlouis Grandlouis commented Apr 19, 2024

Trying to satisfy this ticket -> #1044

Update: I was only able to delay the "reset"/"update" of the m2m rows until afterCommit so all hooks get access to the m2m relation changes on the changes.fields proxy

Update 2: Now the JoinRow has an op fields that indicates the state it has on the flush cycle, whether it is pending, flushed or completed. We use this flags to indicate if there are changes on the m2m relations.

Support for o2m, o2o and old value still pending 😅

Luis Arturo Muñoz Bogarin added 2 commits April 19, 2024 12:24
… to be called after the hook cycles is evaluated, so we get the changes on m2m relations for every hook
@Grandlouis Grandlouis changed the title M2m change detection follow up feat: m2m change detection follow up Apr 19, 2024
@Grandlouis Grandlouis marked this pull request as ready for review April 22, 2024 15:42
Copy link
Collaborator

@stephenh stephenh left a comment

Choose a reason for hiding this comment

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

Hey @Grandlouis ; thanks for the PR! I'd like to try using a JoinRow.op flag instead and see how that works; it will be similar to how InstanceData.op works, which I think will be nice for clarity, and also probably help us eventually implementing the "use changes to get both old value + new value".

packages/orm/src/EntityManager.ts Outdated Show resolved Hide resolved
packages/orm/src/EntityManager.ts Outdated Show resolved Hide resolved
packages/orm/src/drivers/Driver.ts Outdated Show resolved Hide resolved
packages/orm/src/drivers/PostgresDriver.ts Outdated Show resolved Hide resolved
packages/orm/src/drivers/PostgresDriver.ts Outdated Show resolved Hide resolved
@Grandlouis Grandlouis requested a review from stephenh May 17, 2024 20:33
Copy link
Collaborator

@stephenh stephenh left a comment

Choose a reason for hiding this comment

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

This is great @Grandlouis , thank you!

@stephenh stephenh merged commit ed4be3d into joist-orm:main May 19, 2024
5 checks passed
stephenh pushed a commit that referenced this pull request May 19, 2024
# [1.168.0](v1.167.0...v1.168.0) (2024-05-19)

### Features

* m2m change detection follow up ([#1046](#1046)) ([ed4be3d](ed4be3d))
@stephenh
Copy link
Collaborator

🎉 This PR is included in version 1.168.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

None yet

2 participants