Skip to content

Add withAll() and withAllRecursive() to Query Builder#94

Merged
cuebit merged 8 commits intovuex-orm:masterfrom
M3psipax:master
Nov 11, 2021
Merged

Add withAll() and withAllRecursive() to Query Builder#94
cuebit merged 8 commits intovuex-orm:masterfrom
M3psipax:master

Conversation

@M3psipax
Copy link
Copy Markdown
Contributor

@M3psipax M3psipax commented Nov 5, 2021

Type of PR:

  • Bugfix
  • Feature
  • Refactor
  • Code style update
  • Build-related changes
  • Test
  • Documentation
  • Other, please describe:

Breaking changes:

  • No
  • Yes

Details

Adds withAll() and withAllRecursive() utility methods to fetch all relationships on a model.

Still needs a lot more unit tests though.

Copy link
Copy Markdown
Member

@kiaking kiaking left a comment

Choose a reason for hiding this comment

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

@M3psipax Thank you so much for the PR! Looking good.

Can we have the test case as a separate file? Maybe named like test/feature/relations/recursive/recursive.spec.ts?

@M3psipax
Copy link
Copy Markdown
Contributor Author

M3psipax commented Nov 8, 2021

Hey @kiaking I reverted the changes to belongs_to_retrieve.spec.ts and created a new spec for it. I called it eager_loads instead of recursive because it does not only test withAllRecursive(), but also withAll().

If you run the test, you'll see that one is failing at: https://github.com/M3psipax/vuex-orm-next/blob/97e6ee8af47dfbb25e53127fa6d4ef43cbb3a297/test/feature/relations/eager_loads/eager_loads.spec.ts#L67

When loading only top level relations, I would expect all further relations to be filled with null, just as they would be when loading only a specific relation on an object using with("relation"). However, they seem to be undefined instead. I'm not sure why that is. Can I get some help there?

@cuebit
Copy link
Copy Markdown
Member

cuebit commented Nov 8, 2021

@M3psipax i wouldn't worry about the relations being undefined, that's a wider concern as mentioned in #96.

@M3psipax
Copy link
Copy Markdown
Contributor Author

M3psipax commented Nov 8, 2021

Okay, I adjusted the test to allow undefined for that.

@cuebit cuebit added the enhancement New feature or request label Nov 8, 2021
@cuebit cuebit linked an issue Nov 8, 2021 that may be closed by this pull request
cuebit and others added 3 commits November 11, 2021 00:03
Co-Authored-By: M3psipax <15832631+M3psipax@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Nov 11, 2021

Codecov Report

Merging #94 (5963742) into master (e203096) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #94   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           36        38    +2     
  Lines         1122      1175   +53     
  Branches       164       172    +8     
=========================================
+ Hits          1122      1175   +53     
Impacted Files Coverage Δ
src/query/Query.ts 100.00% <100.00%> (ø)
src/repository/Repository.ts 100.00% <100.00%> (ø)
src/model/Model.ts 100.00% <0.00%> (ø)
src/model/attributes/relations/MorphOne.ts 100.00% <0.00%> (ø)
.../model/decorators/attributes/relations/MorphOne.ts 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e203096...5963742. Read the comment docs.

Copy link
Copy Markdown
Member

@cuebit cuebit left a comment

Choose a reason for hiding this comment

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

@kiaking I'll add documentation for these in a separate PR 👍

@cuebit cuebit merged commit cf18192 into vuex-orm:master Nov 11, 2021
@M3psipax
Copy link
Copy Markdown
Contributor Author

Hey, thanks for merging. When is the next release planned?

@kiaking
Copy link
Copy Markdown
Member

kiaking commented Nov 12, 2021

As soon as the docs for this feature is ready, we can release a new version 👍

👀 @cuebit 😃

@cuebit cuebit mentioned this pull request Nov 12, 2021
10 tasks
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

Successfully merging this pull request may close these issues.

Loading all relationships on a Model

3 participants