sequelize / sequelize/sequelize

Deduping of belongsToMany associations

Open
#9,618 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: awaiting response type: feature
Dominant language
TypeScript
Stars
30.4k
Forks
4.3k
Avg merge
1d 6h
Merged PRs (30d)
68

Description

I have tried to discuss this on the Slack channel but didn't get much response. I am aware of the on-going issue where belongsToMany-association with a custom unique index is not supported. I would like to make a change were it checks if the through-table has a custom unique index (other then the two foreign keys) and if so check disable the deduping of the items. Only I am have been trying to find the code which does the deduping but I haven't been able to find it.

If the maintainers of this library find my idea mentioned above feasible (worth a PR) would you be able to point to the right parts of the code base? Thank you!

If you use raw: true the deduping is disabled, so it has to be somewhere around there. Does Sequelize have a helper method to convert the raw output in the model fields?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names belongsToMany associations, the through table, and raw: true, but no file or test. Start by tracing where normal query results are deduplicated versus raw results; done means a custom unique index on the through table prevents that deduplication while raw behavior remains understood.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.