Skip to content

Update polymorphic-associations.md#478

Open
sooxt98 wants to merge 2 commits intosequelize:mainfrom
sooxt98:patch-1
Open

Update polymorphic-associations.md#478
sooxt98 wants to merge 2 commits intosequelize:mainfrom
sooxt98:patch-1

Conversation

@sooxt98
Copy link
Copy Markdown

@sooxt98 sooxt98 commented May 28, 2023

the comment should be two way scoping to prevent excess eagerLoading when using Comment.findAll, with this it only include the specific commentableType

the comment should be two way scoping to prevent excess eagerLoading when using Comment.findAll, with this it only include the specific commentableType
@ephys
Copy link
Copy Markdown
Member

ephys commented May 28, 2023

That will only work when eager loading, but will break all lazy-loaders. I do not recommend doing this. I also don't see what this fixes. Could you provide a query that does not behave as expected?

@sooxt98
Copy link
Copy Markdown
Author

sooxt98 commented May 28, 2023

@ephys it added these 3 lines when using Rating.findAll , which prevent all three included rateableType to find together when id = xxx , because theres always all three rateableType result come out together for each rating, but it should be just one, which i think this will affect the performance

image

@ephys
Copy link
Copy Markdown
Member

ephys commented Jun 17, 2023

There is a warning about it in the new documentation: https://648dd325deb93b14ad86d83a--sequelize-site.netlify.app/docs/v7/associations/polymorphic-associations/#single-model-single-foreign-key-polymorphic-associations

But the proposed solution is unfortunately not something we can put in our documentation, as it will only lead to more issues

Right now the best we can do is copy that warning in the Sequelize 6 documentation

@sooxt98 sooxt98 requested a review from a team as a code owner April 11, 2024 20:17
@sooxt98 sooxt98 requested review from WikiRik and ephys April 11, 2024 20:17
@sequelize-bot sequelize-bot bot added the conflicted This PR has merge conflicts and will not be present in the list of PRs to review label Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicted This PR has merge conflicts and will not be present in the list of PRs to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants