You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
By clicking “Sign up for GitHub”, you agree to our
terms of service
and
privacy statement
. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Problem
Model.count
is returning
NaN
because Mysql returns an empty string when grouping.
SELECT count(*) AS `count` FROM `Model` AS `Model` WHERE (`Model`.`deleted_at` IS NULL AND `Model`.`a_model`='Post' AND `Model`.`a_foreign_key`=186);
# count: 0
SELECT count(*) AS `count` FROM `Model` AS `Model` WHERE (`Model`.`deleted_at` IS NULL AND `Model`.`a_model`='Post' AND `Model`.`a_foreign_key`=186) GROUP BY `Model`.`user_id`;
# count: ''
If there are values to group up, everything works as expected, but if not, MySQL returns an empty string instead of a
0
(zero).
Solution
Return parsed Int, or
0
at
queryInterface
;
@BridgeAR
@cusspvz
Would you be so kind and check if your issue still persists and if, if my linked fix fixes the issue?
Think your PR fixes this issue.
@janmeier
@cusspvz
What result do you expect - a count for each group, or the number of groups?
Honestly i din't quite remember, but after checking our internal issue related with this and the image it had, i think it is the number of users with entries with the polymorphed model.
Problem was on
mysql
returning an empty string instead of zero, you can check that behavior with
mysql-client
.