Skip to content

Closes #3019, Model.count should not return NaN - #6101

Merged
janmeier merged 1 commit into
sequelize:masterfrom
sushantdhiman:fix-3019
Jun 14, 2016
Merged

janmeier merged 1 commit into
sequelize:masterfrom
sushantdhiman:fix-3019

Conversation

@sushantdhiman

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?

Description of change

Closes #3019, Issue seems to be fixed already. Test case to prevent regression.

@janmeier

Copy link
Copy Markdown
Member

The issue mentions a grouping that returns an empty string - Which we try to parse as an int

@sushantdhiman

Copy link
Copy Markdown
Contributor Author

Thanks @janmeier

@sushantdhiman

Copy link
Copy Markdown
Contributor Author

Should it return Integer or String, keeping in mind large counts ?

@sushantdhiman

Copy link
Copy Markdown
Contributor Author

Cases

  1. So when we use group, its not possible to get null record like this [ { count: null }, { count: 3} ], group by will not return it. It will result into [ { count: 3 } ] ( ignored null )
  2. But its still possible to have [ ] when group doesn't return anything.
  3. When a empty result condition run ( without group) then result is 0 Integer

Case 2 should keep using [] because user must be expecting Array with group.

Your comments @mickhansen @janmeier

@janmeier

Copy link
Copy Markdown
Member

Agreed with regards to 2.

@janmeier

Copy link
Copy Markdown
Member

Yay, github now sends notification emails on new pushes to PRs 🎉 !

@sushantdhiman

Copy link
Copy Markdown
Contributor Author

Don't worry I'll still link you to all PRs 😆

@janmeier
janmeier merged commit 1b49858 into sequelize:master Jun 14, 2016
@sushantdhiman
sushantdhiman deleted the fix-3019 branch June 14, 2016 09:36
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.

Model.count returning NaN because Mysql returns an empty string

2 participants