Repository navigation
Fix count queries with includes - #6190
Conversation
|
Yeah, this "optimization" is causing too many problems to many sense - Lets KISS ;) |
|
I backported all the comments from the v4 branch and included the attributes fix too. |
Add changelog entry
Add changelog entry
|
This isn't quite done, since it clashes with typescript. 'distinct' works now in findAndCountAll for 3.24.3, but it was never added to FindOptions so Typescript compiler complains since distinct is in CountOptions. Perhaps there should be a FindAndCountOptions? But the error can be ignored (I think?) since distinct makes the count returned by findAndCountAll correct. xxxx\xxx\xxxx.ts(229,17): error TS2345: Argument of type '{ include: (TimeZoneModel | { model: UnitModel; as: string; include: any; attributes: string[]; }...' is not assignable to parameter of type 'FindOptions'. Edit: I found a workaround to get rid of the annoying Typescript error for distinct not being in FindOptions - create a new object typed to :any and then pass that to findAndCountAll e.g. let sequelizeQuery:any = {include: [... |
|
@netdragonboberb This is not a typescript project. Please open issue on https://github.com/DefinitelyTyped/DefinitelyTyped, that's where the type definitions are maintained. |
|
@alitaheri @netdragonboberb I maintain the TypeScript typings at https://github.com/types/npm-sequelize, please open an issue there. |
Pull Request check-list
npm run testornpm run test-DIALECTpass with this change (including linting)?Futurein the changelog?Description of change
Currently the
countandfindAndCountand diverge in the build queries with the same query object. This unifies those two, removes unnecessary duplicated checks and fixes a bug which quite a few people ran into by optimistically removing all includes for performance reasons.I want to have fast queries but primarily stability is important. I'm willing to have a look at this in more detail to improve the performance later.
Fixes #1142 #2145 #2968 #3936 #4146 #4194 #5526 #5680 #6123 (I went through to many issues to always be certain but likely all get fixed by this).
Fixes partly #2886 #3319 #4737 #5465 (people that commented had similar issues or a part of the issue is fixed with this)
Somehwat related #2713
I know there should be tests included and I'll add them as soon as you're happy with the other code.