Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

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

Do not cast decimal to integer #563

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions ext/mysql2/result.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,7 @@ static VALUE rb_mysql_result_fetch_row(VALUE self, ID db_timezone, ID app_timezo
break;
case MYSQL_TYPE_DECIMAL: /* DECIMAL or NUMERIC field */
case MYSQL_TYPE_NEWDECIMAL: /* Precision math DECIMAL or NUMERIC field (MySQL 5.0.3 and up) */
if (fields[i].decimals == 0) {
val = rb_cstr2inum(row[i], 10);
} else if (strtod(row[i], NULL) == 0.000000){
if (strtod(row[i], NULL) == 0.000000){
val = rb_funcall(cBigDecimal, intern_new, 1, opt_decimal_zero);
}else{
val = rb_funcall(cBigDecimal, intern_new, 1, rb_str_new(row[i], fieldLengths[i]));
Expand Down