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

Support change tracking on inverse side of M:N relations #4564

Closed
B4nan opened this issue Jul 27, 2023 · 1 comment
Closed

Support change tracking on inverse side of M:N relations #4564

B4nan opened this issue Jul 27, 2023 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@B4nan
Copy link
Member

B4nan commented Jul 27, 2023

Is your feature request related to a problem? Please describe.
Currently, only the owning sides of M:N relations are checked for changes. Working with inverse side works as long as you are adding or removing specific and populated items, but it won't work if you try to add not loaded reference instead. Also calling removeAll() on inverse side is not working at all.

Describe the solution you'd like
We should probably check both sides of M:N relations, and try to compute the diff respecting both.

Describe alternatives you've considered
If this proves to be too hard, we should at least throw instead of silently ignoring those problematic actions.

Additional context
This has been one of the common pain points since inception.

@B4nan B4nan added the enhancement New feature or request label Jul 27, 2023
@B4nan B4nan added this to the 6.0 milestone Jul 27, 2023
B4nan added a commit that referenced this issue Oct 8, 2023
Implements diffing for inverse sides of M:N relations (for SQL drivers).
This was previously working only if the items were initialized.

```ts
const tag = await em.findOne(BookTag, 1);
// tag.books in an inverse side
tag.books.add(em.getReference(Book, 123));
await em.flush();
```

The M:N updates are now also batched.

Closes #4564
@B4nan
Copy link
Member Author

B4nan commented Oct 8, 2023

Closing as implemented in v6 via #4798

@B4nan B4nan closed this as completed Oct 8, 2023
B4nan added a commit that referenced this issue Oct 17, 2023
Implements diffing for inverse sides of M:N relations (for SQL drivers).
This was previously working only if the items were initialized.

```ts
const tag = await em.findOne(BookTag, 1);
// tag.books in an inverse side
tag.books.add(em.getReference(Book, 123));
await em.flush();
```

The M:N updates are now also batched.

Closes #4564
B4nan added a commit that referenced this issue Oct 21, 2023
Implements diffing for inverse sides of M:N relations (for SQL drivers).
This was previously working only if the items were initialized.

```ts
const tag = await em.findOne(BookTag, 1);
// tag.books in an inverse side
tag.books.add(em.getReference(Book, 123));
await em.flush();
```

The M:N updates are now also batched.

Closes #4564
B4nan added a commit that referenced this issue Oct 25, 2023
Implements diffing for inverse sides of M:N relations (for SQL drivers).
This was previously working only if the items were initialized.

```ts
const tag = await em.findOne(BookTag, 1);
// tag.books in an inverse side
tag.books.add(em.getReference(Book, 123));
await em.flush();
```

The M:N updates are now also batched.

Closes #4564
B4nan added a commit that referenced this issue Nov 2, 2023
Implements diffing for inverse sides of M:N relations (for SQL drivers).
This was previously working only if the items were initialized.

```ts
const tag = await em.findOne(BookTag, 1);
// tag.books in an inverse side
tag.books.add(em.getReference(Book, 123));
await em.flush();
```

The M:N updates are now also batched.

Closes #4564
B4nan added a commit that referenced this issue Nov 5, 2023
Implements diffing for inverse sides of M:N relations (for SQL drivers).
This was previously working only if the items were initialized.

```ts
const tag = await em.findOne(BookTag, 1);
// tag.books in an inverse side
tag.books.add(em.getReference(Book, 123));
await em.flush();
```

The M:N updates are now also batched.

Closes #4564
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant