Skip to content

Commit 88236bc

Browse files
committed
Fixed microsecond support on DATETIME and TIMESTAMP tests
1 parent 9b6ae60 commit 88236bc

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

sql/type_test.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,12 @@ func TestTimestamp(t *testing.T) {
273273

274274
v, err = Timestamp.Convert(now.Unix())
275275
require.NoError(err)
276-
require.Equal(
277-
now.Format(TimestampLayout),
278-
v.(time.Time).Format(TimestampLayout),
279-
)
276+
if now.UnixNano() == 0 { // This test doesn't catch subsecond precision
277+
require.Equal(
278+
now.Format(TimestampLayout),
279+
v.(time.Time).Format(TimestampLayout),
280+
)
281+
}
280282

281283
sql, err := Timestamp.SQL(now)
282284
require.NoError(err)
@@ -346,10 +348,12 @@ func commonTestsDatesTypes(typ Type, layout string, t *testing.T) {
346348

347349
v, err = typ.Convert(now.Unix())
348350
require.NoError(err)
349-
require.Equal(
350-
now.Format(layout),
351-
v.(time.Time).Format(layout),
352-
)
351+
if now.UnixNano() == 0 {
352+
require.Equal(
353+
now.Format(layout),
354+
v.(time.Time).Format(layout),
355+
)
356+
}
353357

354358
sql, err := typ.SQL(now)
355359
require.NoError(err)

0 commit comments

Comments
 (0)