Skip to content

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

Open

Description

@JaRoMasterDev

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions