Skip to content

Commit 56b46c8

Browse files
sodabrewjustincase
authored andcommitted
Support for microseconds in prepared statements
1 parent ca91bf4 commit 56b46c8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

ext/mysql2/result.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ static VALUE rb_mysql_result_fetch_row_stmt(VALUE self, MYSQL_FIELD * fields, co
427427
break;
428428
case MYSQL_TYPE_TIME: // MYSQL_TIME
429429
ts = (MYSQL_TIME*)result_buffer->buffer;
430-
val = rb_funcall(rb_cTime, args->db_timezone, 6, opt_time_year, opt_time_month, opt_time_month, UINT2NUM(ts->hour), UINT2NUM(ts->minute), UINT2NUM(ts->second));
430+
val = rb_funcall(rb_cTime, args->db_timezone, 7, opt_time_year, opt_time_month, opt_time_month, UINT2NUM(ts->hour), UINT2NUM(ts->minute), UINT2NUM(ts->second), ULONG2NUM(ts->second_part));
431431
if (!NIL_P(args->app_timezone)) {
432432
if (args->app_timezone == intern_local) {
433433
val = rb_funcall(val, intern_localtime, 0);
@@ -458,7 +458,7 @@ static VALUE rb_mysql_result_fetch_row_stmt(VALUE self, MYSQL_FIELD * fields, co
458458
}
459459
}
460460
} else {
461-
val = rb_funcall(rb_cTime, args->db_timezone, 6, UINT2NUM(ts->year), UINT2NUM(ts->month), UINT2NUM(ts->day), UINT2NUM(ts->hour), UINT2NUM(ts->minute), UINT2NUM(ts->second));
461+
val = rb_funcall(rb_cTime, args->db_timezone, 7, UINT2NUM(ts->year), UINT2NUM(ts->month), UINT2NUM(ts->day), UINT2NUM(ts->hour), UINT2NUM(ts->minute), UINT2NUM(ts->second), ULONG2NUM(ts->second_part));
462462
if (!NIL_P(args->app_timezone)) {
463463
if (args->app_timezone == intern_local) {
464464
val = rb_funcall(val, intern_localtime, 0);

ext/mysql2/statement.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ static VALUE execute(int argc, VALUE *argv, VALUE self) {
287287
MYSQL_TIME t;
288288
VALUE rb_time = argv[i];
289289
memset(&t, 0, sizeof(MYSQL_TIME));
290-
t.second_part = 0;
291290
t.neg = 0;
291+
t.second_part = FIX2INT(rb_funcall(rb_time, rb_intern("usec"), 0));
292292
t.second = FIX2INT(rb_funcall(rb_time, rb_intern("sec"), 0));
293293
t.minute = FIX2INT(rb_funcall(rb_time, rb_intern("min"), 0));
294294
t.hour = FIX2INT(rb_funcall(rb_time, rb_intern("hour"), 0));

0 commit comments

Comments
 (0)