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

Update polymorphic-associations.md #478

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

sooxt98
Copy link

@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
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
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
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 ephys and WikiRik 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