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(core): respect updates to M:N inverse sides and batch them #4798

Merged
merged 1 commit into from
Oct 8, 2023

Conversation

B4nan
Copy link
Member

@B4nan B4nan commented 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.

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 B4nan mentioned this pull request Oct 8, 2023
22 tasks
@codecov
Copy link

codecov bot commented Oct 8, 2023

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Files Coverage Δ
packages/core/src/EntityManager.ts 97.42% <100.00%> (ø)
packages/core/src/drivers/IDatabaseDriver.ts 100.00% <ø> (ø)
packages/core/src/entity/ArrayCollection.ts 98.54% <100.00%> (-1.46%) ⬇️
packages/core/src/entity/Collection.ts 97.41% <100.00%> (ø)
...ackages/core/src/unit-of-work/ChangeSetComputer.ts 98.93% <100.00%> (ø)
packages/core/src/unit-of-work/UnitOfWork.ts 99.65% <100.00%> (ø)
packages/core/src/utils/Utils.ts 98.75% <100.00%> (+<0.01%) ⬆️
packages/knex/src/PivotCollectionPersister.ts 100.00% <100.00%> (ø)
packages/knex/src/query/QueryBuilder.ts 99.14% <100.00%> (ø)
packages/core/src/drivers/DatabaseDriver.ts 97.79% <66.66%> (-1.65%) ⬇️
... and 1 more

📢 Thoughts on this report? Let us know!.

@B4nan B4nan merged commit 4ca54e5 into v6 Oct 8, 2023
6 of 8 checks passed
@B4nan B4nan deleted the batch-pivot-queries branch October 8, 2023 18:01
B4nan added a commit that referenced this pull request 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 pull request 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 pull request 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 pull request 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 pull request 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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant