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

Sequelize query runs infinite when using $get with eager loading #1727

Open
1 of 2 tasks
JaRoMasterDev opened this issue Aug 6, 2024 · 0 comments
Open
1 of 2 tasks

Comments

@JaRoMasterDev
Copy link

JaRoMasterDev commented Aug 6, 2024

Issue

I have tried using eager loading in combination with the $get method on a sequelize object:

await user?.$get("following", {
	order: [["name", "ASC"]],
	limit: USERS_PER_PAGE,
	offset: (page - 1) * USERS_PER_PAGE,
	where,
	include: Gym
}

The query worked fine, until I added the include parameter. It returns an Array of users that have a 1:1 relation to the Gym model through a foreign key in the Gym model. Including the Gym works fine with the findOne and findMany method.

This approach leads to the Promise neither resolving nor rejecting with an error.

Versions

  • sequelize: ^6.31.1
  • sequelize-typescript: ^2.1.5
  • typescript: ^5.0.4

Issue type

  • bug report
  • feature request

Actual behavior

The returned Promise of $get doesn't get resolved or rejected.

Expected behavior

The user should have a attribute gym that contains the gym's information if the user is related to a gym.

Steps to reproduce

Have 2 Models. Add a 1:n relation between Model A and itself. Add a 1:1 relation between Model A and B. Get all related Model A's from a specific instance of Model A using the $get method and include Model B

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

No branches or pull requests

1 participant