Skip to content

Commit 1c894d6

Browse files
authored
Merge pull request #128 from planetscale/add-microseconds
Add microseconds and use time offset
2 parents 524749e + 5e8e5c1 commit 1c894d6

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

cmd/internal/types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func formatISO8601(mysqlType query.Type, value sqltypes.Value) Value {
244244
layout = time.DateOnly
245245
} else {
246246
formatString = "2006-01-02 15:04:05"
247-
layout = time.RFC3339
247+
layout = "2006-01-02T15:04:05.000000-07:00"
248248
}
249249

250250
var (

cmd/internal/types_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,15 @@ func TestCanFormatISO8601Values(t *testing.T) {
184184
output := QueryResultToRecords(&input, &PlanetScaleSource{})
185185
assert.Equal(t, 3, len(output))
186186
row := output[0]
187-
assert.Equal(t, "2025-02-14T08:08:08Z", row["datetime_created_at"].(sqltypes.Value).ToString())
187+
assert.Equal(t, "2025-02-14T08:08:08.000000+00:00", row["datetime_created_at"].(sqltypes.Value).ToString())
188188
assert.Equal(t, "2025-02-14", row["date_created_at"].(sqltypes.Value).ToString())
189-
assert.Equal(t, "2025-02-14T08:08:08Z", row["timestamp_created_at"].(sqltypes.Value).ToString())
189+
assert.Equal(t, "2025-02-14T08:08:08.000000+00:00", row["timestamp_created_at"].(sqltypes.Value).ToString())
190190
nullRow := output[1]
191191
assert.Equal(t, nil, nullRow["datetime_created_at"])
192192
assert.Equal(t, nil, nullRow["date_created_at"])
193193
assert.Equal(t, nil, nullRow["timestamp_created_at"])
194194
zeroRow := output[2]
195-
assert.Equal(t, "1970-01-01T00:00:00Z", zeroRow["datetime_created_at"].(sqltypes.Value).ToString())
195+
assert.Equal(t, "1970-01-01T00:00:00.000000+00:00", zeroRow["datetime_created_at"].(sqltypes.Value).ToString())
196196
assert.Equal(t, "1970-01-01", zeroRow["date_created_at"].(sqltypes.Value).ToString())
197-
assert.Equal(t, "1970-01-01T00:00:00Z", zeroRow["timestamp_created_at"].(sqltypes.Value).ToString())
197+
assert.Equal(t, "1970-01-01T00:00:00.000000+00:00", zeroRow["timestamp_created_at"].(sqltypes.Value).ToString())
198198
}

0 commit comments

Comments
 (0)