fix(go): write tdengine timestamps as epoch millis
This commit is contained in:
@@ -420,7 +420,7 @@ func literal(value any) string {
|
||||
}
|
||||
switch typed := value.(type) {
|
||||
case time.Time:
|
||||
return "'" + typed.UTC().Format("2006-01-02 15:04:05.000") + "'"
|
||||
return strconv.FormatInt(typed.UnixMilli(), 10)
|
||||
case string:
|
||||
return "'" + quote(typed) + "'"
|
||||
case envelope.ParseStatus:
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"database/sql"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"lingniu-vehicle-ingest/go/vehicle-gateway/internal/envelope"
|
||||
)
|
||||
@@ -151,6 +152,14 @@ func TestWriterLeavesParsedJSONEmptyWhenNoParsedPayload(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTimeLiteralsUseEpochMilliseconds(t *testing.T) {
|
||||
value := time.Date(2026, 7, 3, 1, 12, 59, 77_000_000, time.UTC)
|
||||
|
||||
if got, want := literal(value), "1783041179077"; got != want {
|
||||
t.Fatalf("time literal = %s, want %s", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriterSkipsSparseDerivedRows(t *testing.T) {
|
||||
exec := &recordingExec{}
|
||||
writer := NewWriter(exec)
|
||||
|
||||
Reference in New Issue
Block a user