diff --git a/bulkcopy_test.go b/bulkcopy_test.go index 5de35154..a241ce13 100644 --- a/bulkcopy_test.go +++ b/bulkcopy_test.go @@ -58,6 +58,7 @@ func TestBulkcopy(t *testing.T) { {"test_date_2", "2015-06-07", time.Date(2015, 6, 7, 0, 0, 0, 0, time.UTC)}, {"test_time", time.Date(2010, 11, 12, 13, 14, 15, 123000000, time.UTC), time.Date(1, 1, 1, 13, 14, 15, 123000000, time.UTC)}, {"test_time_2", "13:14:15.1230000", time.Date(1, 1, 1, 13, 14, 15, 123000000, time.UTC)}, + {"test_time_0", "13:14:15", time.Date(1, 1, 1, 13, 14, 15, 0, time.UTC)}, {"test_tinyint", 255, nil}, {"test_smallint", 32767, nil}, {"test_smallintn", nil, nil}, @@ -256,6 +257,7 @@ func setupTable(ctx context.Context, t *testing.T, conn *sql.Conn, tableName str [test_date_2] [date] NULL, [test_time] [time](7) NULL, [test_time_2] [time](7) NULL, + [test_time_0] [time](0) NULL, [test_smallmoney] [smallmoney] NULL, [test_money] [money] NULL, [test_tinyint] [tinyint] NULL, diff --git a/types.go b/types.go index 87803416..2627c18e 100644 --- a/types.go +++ b/types.go @@ -915,8 +915,10 @@ func decodeTime(scale uint8, buf []byte) time.Time { func encodeTime(hour, minute, second, ns, scale int) (buf []byte) { seconds := hour*3600 + minute*60 + second - buf = make([]byte, calcTimeSize(scale)) + timeSize := calcTimeSize(scale) + buf = make([]byte, timeSize+2) encodeTimeInt(seconds, ns, scale, buf) + buf = buf[:timeSize] return }