Support time values with nanosecond precision

This commit is contained in:
Micah Stetson
2012-12-29 16:36:29 -08:00
parent f65db67ea3
commit ce139f706b
2 changed files with 16 additions and 15 deletions

View File

@@ -251,7 +251,7 @@ func TestTimestamp(t *testing.T) {
}
timestamp1 := time.Date(2012, time.April, 6, 22, 50, 0, 0, time.UTC)
timestamp2 := time.Date(2006, time.January, 2, 15, 4, 5, 3000000, time.UTC)
timestamp2 := time.Date(2006, time.January, 2, 15, 4, 5, 123456789, time.UTC)
tests := []struct {
value interface{}
expected time.Time
@@ -263,7 +263,7 @@ func TestTimestamp(t *testing.T) {
{timestamp1.In(time.FixedZone("TEST", -7*3600)), timestamp1},
{"2012-11-04", time.Date(2012, time.November, 4, 0, 0, 0, 0, time.UTC)},
{timestamp2, timestamp2},
{"2006-01-02 15:04:05.003", timestamp2},
{"2006-01-02 15:04:05.123456789", timestamp2},
}
for i := range tests {
_, err = db.Exec("INSERT INTO foo(id, ts, dt) VALUES(?, ?, ?)", i, tests[i].value, tests[i].value)