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

Composite primary key brokes respose total #343

Open
elaijuh opened this issue Feb 18, 2020 · 1 comment
Open

Composite primary key brokes respose total #343

elaijuh opened this issue Feb 18, 2020 · 1 comment
Labels

Comments

@elaijuh
Copy link

elaijuh commented Feb 18, 2020

q.include = q.include || [];

This line makes sequelize to use primary key instead of * while options.col is not defined in model beforeCount hook. That causes count on the first primary key which leads to unexpected result. I think it should be documented somewhere.

@daffl daffl added the bug label Apr 29, 2020
@1valdis
Copy link

1valdis commented Jul 6, 2021

Just stumbled on this. Waiting for a fix, but until then try adding this to your Sequelize model (syntax as of Sequelize v4):

hooks: {
  beforeCount(options) {
    options.distinct = false;
  },
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants