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

page parameter "total" is not the actual number of items in the database when using composite primary key #2869

Closed
Leo843 opened this issue Nov 8, 2022 · 2 comments

Comments

@Leo843
Copy link

Leo843 commented Nov 8, 2022

Description

When a GET request is made to the REST API, parameter "total" in the response is not the actual number of items in the database table.

This behavior occurs when a service uses Sequelize with PostgreSQL and the model is defined with a composite primary key (more than one primary key).

Steps to reproduce

I made a repo to reproduce the issue. Clone the repository and run docker compose run test-runner.

Expected behavior

Parameter "total" must always be the actual number of items in the table, even when the model uses a composite primary key.

@daffl
Copy link
Member

daffl commented Nov 8, 2022

This is likely a duplicate of feathersjs-ecosystem/feathers-sequelize#343

@Leo843
Copy link
Author

Leo843 commented Nov 9, 2022

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;
  },
},

Originally posted by @1valdis in feathersjs-ecosystem/feathers-sequelize#343 (comment)

Doing this, fixed the issue for me.

@Leo843 Leo843 closed this as completed Nov 9, 2022
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

2 participants