Skip to content

MorphTo Relation #107

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

Closed
wants to merge 25 commits into from
Closed

Conversation

ryandialpad
Copy link
Contributor

@ryandialpad ryandialpad commented Nov 19, 2021

Type of PR:

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

Breaking changes:

  • No
  • Yes

Details

Implements MorphTo relation, building off of the refactor by @kiaking. I have addressed the two discussed fixes that we wanted to add.

  1. Remove results argument from match method in each relation and use the query to eager load the results instead.
  2. Copy parent query constraints to the new related queries -> need to test this locally and further investigate

I have also addressed an issue from the refactor where multiple results from the same related model would be missing their related data as a result of the query constraints carrying forward in the shared queries.

TODO:

  1. Gather early feedback & make adjustments
  2. Cleanup tests
  3. Further test query constraints to ensure that they are working correctly with this relation

@codecov
Copy link

codecov bot commented Nov 19, 2021

Codecov Report

Merging #107 (55b8bdc) into master (8d5245a) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #107   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           38        40    +2     
  Lines         1153      1252   +99     
  Branches       185       196   +11     
=========================================
+ Hits          1153      1252   +99     
Impacted Files Coverage Δ
src/model/attributes/relations/Relation.ts 100.00% <ø> (ø)
src/database/Database.ts 100.00% <100.00%> (ø)
src/model/Model.ts 100.00% <100.00%> (ø)
src/model/attributes/relations/BelongsTo.ts 100.00% <100.00%> (ø)
src/model/attributes/relations/HasMany.ts 100.00% <100.00%> (ø)
src/model/attributes/relations/HasManyBy.ts 100.00% <100.00%> (ø)
src/model/attributes/relations/HasOne.ts 100.00% <100.00%> (ø)
src/model/attributes/relations/MorphOne.ts 100.00% <100.00%> (ø)
src/model/attributes/relations/MorphTo.ts 100.00% <100.00%> (ø)
...c/model/decorators/attributes/relations/MorphTo.ts 100.00% <100.00%> (ø)
... and 3 more

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 8d5245a...55b8bdc. Read the comment docs.

@ryandialpad ryandialpad changed the title WIP MorphTo Relation MorphTo Relation Nov 19, 2021
…ted data as we don't know if type or id will be nullable
Copy link
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.

Looks good so far, left a few comments for your consideration 👍

@ryandialpad ryandialpad mentioned this pull request Nov 22, 2021
10 tasks
@ryandialpad
Copy link
Contributor Author

Already merged into #106

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.

3 participants