feathersjs-ecosystem / feathers-sequelize

A Feathers service adapter for the Sequelize ORM. Supporting MySQL, MariaDB, Postgres, SQLite, and SQL Server
MIT License
208 stars 74 forks source link

Composite primary key brokes respose total #343

Open elaijuh opened 4 years ago

elaijuh commented 4 years ago

https://github.com/feathersjs-ecosystem/feathers-sequelize/blob/165288f644e5b5a54a5dca6bcd10f4ad3d8d67ee/lib/index.js#L144

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.

1valdis commented 3 years ago

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