Repository navigation
Fix includes being removed from count queries - #6192
Conversation
| let result; | ||
| const queryObject = { | ||
| include: [this.Project], | ||
| logging: function (sql) { |
There was a problem hiding this comment.
Whats going on with the logging here?
There was a problem hiding this comment.
The logging is used to compare the ouput of the findAndCount count query and the count query. They should always be identical with one minor exception: If you pass attributes in a findAndCount query the attributes should be stripped and in a count they should be kept.
There was a problem hiding this comment.
Hmm, that feels a bit dirty
You could also write this as a unit test, where you verify that the arguments to find and count are correct
|
Good to have you back @BridgeAR ! :) |
|
Comments incorporated. I'm actually thinking about if it's better to not automatically set distinct to true if a include is set. That is the normal database behavior, so it's likely better to go for that one. |
| describe(Support.getTestDialectTeaser('Model'), () => { | ||
| describe.only('method count', () => { | ||
| before(() => { | ||
| this.oldFindAll = current.Model.findAll; |
There was a problem hiding this comment.
You can preface with sandbox = sinon.sandbox.create(), and usesandbox.stub. Then you just need to callsandbox.restore()in afterEach` to reset all the stubs
|
LGTM, would like @mickhansen or @sushantdhiman comments as well |
| }); | ||
| }); | ||
| return Post.sync({ force: true }).then(() => { | ||
| return PostComment.sync({ force: true }); |
There was a problem hiding this comment.
Unnecessary returns in arrow functions, you can do () => ( PostComment.sync({ force: true }) ), Same applies for this whole chain
|
LGTM, I agree that performance check is causing too many issues, we should remove it for now. Later on I would report if there are any significant deviation in performance. |
|
Done. I removed the distinct default too, as this depicts the regular database behavior. |
Add unit test Don't set distinct to true as a default
|
No-no-no-NONET-kill! Pretty sure thats a new record for most issues fixed in one PR :) |
Pull Request check-list
npm run testornpm run test-DIALECTpass with this change (including linting)?Futurein the changelog?Description of change
See #6190 for more details (same fix applied against v.3)