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

fix(core): rework Collection initialization to use em.populate() #4571

Merged
merged 2 commits into from
Aug 1, 2023

Conversation

B4nan
Copy link
Member

@B4nan B4nan commented Jul 31, 2023

This unifies the population mechanism for to-many relations by using the em.populate() internally.

Previously, the Collection.init (and methods using it, e.g. loadItems) were using custom implementation, which in some cases resulting in different results as opposed to em.populate(). With this PR, the init method is also using em.populate, yielding the same results as if you would populate the relation.

Closes #4464

This unifies the population mechanism for to-many relations by using the `em.populate()` internally.

Previously, the `Collection.init` (and methods using it, e.g. `loadItems`) were using custom
implementation, which in some cases resulting in different results as opposed to `em.populate()`.
With this PR, the `init` method is also using `em.populate`, yielding the same results as if you
would populate the relation.

Closes #4464
@codecov
Copy link

codecov bot commented Jul 31, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.01% ⚠️

Comparison is base (ace3e16) 99.38% compared to head (6b2be77) 99.38%.

Additional details and impacted files
@@            Coverage Diff             @@
##               v6    #4571      +/-   ##
==========================================
- Coverage   99.38%   99.38%   -0.01%     
==========================================
  Files         219      219              
  Lines       14859    14845      -14     
  Branches     3440     3443       +3     
==========================================
- Hits        14768    14754      -14     
  Misses         88       88              
  Partials        3        3              
Files Changed Coverage Δ
packages/core/src/entity/ArrayCollection.ts 100.00% <100.00%> (ø)
packages/core/src/entity/Collection.ts 97.15% <100.00%> (-0.28%) ⬇️
packages/core/src/entity/EntityLoader.ts 100.00% <100.00%> (ø)
packages/knex/src/AbstractSqlDriver.ts 99.83% <100.00%> (+<0.01%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@B4nan B4nan merged commit a0805ad into v6 Aug 1, 2023
9 checks passed
@B4nan B4nan deleted the coll-init-populate branch August 1, 2023 17:26
@parisholley
Copy link
Contributor

@B4nan by chance, does this refactor fix a potential issue where calling collection.loadItems() on an already initialized collection (or perhaps uninitialized but one of the resulting items is already in UOW) will cause any mutations (eg: changing a string property) on an item in that collection to be reverted (I assume a hard "refresh" was happening to the UOW). I worked around it for now by instead using entity.populate() (on dev v89). If this change is already in v89 I can issue a pull otherwise, i'll wait to test it again in the latest dev release.

@B4nan
Copy link
Member Author

B4nan commented Aug 4, 2023

Yes, this PR is part of 6.0.0-dev.89.

Keep in mind that em.populate() has refresh: false by default, while the one this PR adds into the coll.init() will have refresh: true.

B4nan added a commit that referenced this pull request Sep 10, 2023
…4571)

This unifies the population mechanism for to-many relations by using the
`em.populate()` internally.

Previously, the `Collection.init` (and methods using it, e.g.
`loadItems`) were using custom implementation, which in some cases
resulting in different results as opposed to `em.populate()`. With this
PR, the `init` method is also using `em.populate`, yielding the same
results as if you would populate the relation.

Closes #4464
B4nan added a commit that referenced this pull request Sep 20, 2023
…4571)

This unifies the population mechanism for to-many relations by using the
`em.populate()` internally.

Previously, the `Collection.init` (and methods using it, e.g.
`loadItems`) were using custom implementation, which in some cases
resulting in different results as opposed to `em.populate()`. With this
PR, the `init` method is also using `em.populate`, yielding the same
results as if you would populate the relation.

Closes #4464
B4nan added a commit that referenced this pull request Sep 24, 2023
…4571)

This unifies the population mechanism for to-many relations by using the
`em.populate()` internally.

Previously, the `Collection.init` (and methods using it, e.g.
`loadItems`) were using custom implementation, which in some cases
resulting in different results as opposed to `em.populate()`. With this
PR, the `init` method is also using `em.populate`, yielding the same
results as if you would populate the relation.

Closes #4464
B4nan added a commit that referenced this pull request Sep 30, 2023
…4571)

This unifies the population mechanism for to-many relations by using the
`em.populate()` internally.

Previously, the `Collection.init` (and methods using it, e.g.
`loadItems`) were using custom implementation, which in some cases
resulting in different results as opposed to `em.populate()`. With this
PR, the `init` method is also using `em.populate`, yielding the same
results as if you would populate the relation.

Closes #4464
B4nan added a commit that referenced this pull request Oct 2, 2023
…4571)

This unifies the population mechanism for to-many relations by using the
`em.populate()` internally.

Previously, the `Collection.init` (and methods using it, e.g.
`loadItems`) were using custom implementation, which in some cases
resulting in different results as opposed to `em.populate()`. With this
PR, the `init` method is also using `em.populate`, yielding the same
results as if you would populate the relation.

Closes #4464
B4nan added a commit that referenced this pull request Oct 17, 2023
…4571)

This unifies the population mechanism for to-many relations by using the
`em.populate()` internally.

Previously, the `Collection.init` (and methods using it, e.g.
`loadItems`) were using custom implementation, which in some cases
resulting in different results as opposed to `em.populate()`. With this
PR, the `init` method is also using `em.populate`, yielding the same
results as if you would populate the relation.

Closes #4464
B4nan added a commit that referenced this pull request Oct 21, 2023
…4571)

This unifies the population mechanism for to-many relations by using the
`em.populate()` internally.

Previously, the `Collection.init` (and methods using it, e.g.
`loadItems`) were using custom implementation, which in some cases
resulting in different results as opposed to `em.populate()`. With this
PR, the `init` method is also using `em.populate`, yielding the same
results as if you would populate the relation.

Closes #4464
B4nan added a commit that referenced this pull request Oct 25, 2023
…4571)

This unifies the population mechanism for to-many relations by using the
`em.populate()` internally.

Previously, the `Collection.init` (and methods using it, e.g.
`loadItems`) were using custom implementation, which in some cases
resulting in different results as opposed to `em.populate()`. With this
PR, the `init` method is also using `em.populate`, yielding the same
results as if you would populate the relation.

Closes #4464
B4nan added a commit that referenced this pull request Nov 2, 2023
…4571)

This unifies the population mechanism for to-many relations by using the
`em.populate()` internally.

Previously, the `Collection.init` (and methods using it, e.g.
`loadItems`) were using custom implementation, which in some cases
resulting in different results as opposed to `em.populate()`. With this
PR, the `init` method is also using `em.populate`, yielding the same
results as if you would populate the relation.

Closes #4464
B4nan added a commit that referenced this pull request Nov 5, 2023
…4571)

This unifies the population mechanism for to-many relations by using the
`em.populate()` internally.

Previously, the `Collection.init` (and methods using it, e.g.
`loadItems`) were using custom implementation, which in some cases
resulting in different results as opposed to `em.populate()`. With this
PR, the `init` method is also using `em.populate`, yielding the same
results as if you would populate the relation.

Closes #4464
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

2 participants