Skip to content

Fix includes being removed from count queries - #6192

Merged
janmeier merged 1 commit into
sequelize:masterfrom
fintura:v4-count
Jul 5, 2016
Merged

janmeier merged 1 commit into
sequelize:masterfrom
fintura:v4-count

Conversation

@BridgeAR

@BridgeAR BridgeAR commented Jun 30, 2016 •

Copy link
Copy Markdown
Contributor

Pull Request check-list

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • Does your issue contain a link to existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Have you added an entry under Future in the changelog?

Description of change

See #6190 for more details (same fix applied against v.3)

Comment thread test/integration/model/count.test.js Outdated
let result;
const queryObject = {
include: [this.Project],
logging: function (sql) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats going on with the logging here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@janmeier

janmeier commented Jul 1, 2016

Copy link
Copy Markdown
Member

Good to have you back @BridgeAR ! :)

@BridgeAR

BridgeAR commented Jul 2, 2016 •

Copy link
Copy Markdown
Contributor Author

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;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@janmeier

janmeier commented Jul 3, 2016 •

Copy link
Copy Markdown
Member

LGTM, would like @mickhansen or @sushantdhiman comments as well

Comment thread test/integration/model.test.js Outdated
});
});
return Post.sync({ force: true }).then(() => {
return PostComment.sync({ force: true });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary returns in arrow functions, you can do () => ( PostComment.sync({ force: true }) ), Same applies for this whole chain

@sushantdhiman

Copy link
Copy Markdown
Contributor

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.

@BridgeAR

BridgeAR commented Jul 3, 2016

Copy link
Copy Markdown
Contributor Author

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
@janmeier
janmeier merged commit 4f39a8a into sequelize:master Jul 5, 2016
@janmeier

janmeier commented Jul 5, 2016 •

Copy link
Copy Markdown
Member

No-no-no-NONET-kill! Pretty sure thats a new record for most issues fixed in one PR :)

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

Successfully merging this pull request may close these issues.

3 participants