25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(xugu): format datetime values as writable literals
t8y2b6beefc89e10
diff --git a/agents/drivers/xugu/main.go b/agents/drivers/xugu/main.goindex fd69e91068..3b20fcba32 100644--- a/agents/drivers/xugu/main.go+++ b/agents/drivers/xugu/main.go@@ -6002,13 +6002,27 @@ func quoteIdentifier(value string) string {}func normalizeValue(value any) any {+ return normalizeValueWithType(value, "")+}++// normalizeValueWithType converts a scanned driver value into a JSON-friendly+// value. columnTypeName drives temporal formatting: XuguDB rejects the ISO+// "T"/"Z" literal (E19138 时间值常数错误) that time.RFC3339Nano produces, so+// the round-trippable form is a space-separated wall-clock string. Timezone-+// aware Xugu types keep the numeric offset; timezone-less ones (DATE/DATETIME/+// TIME/TIMESTAMP) drop it so clients do not double-apply a shift. Mirrors the+// oracle-go/kingbase-go timezone-less handling, adapted to Xugu's space rule.+func normalizeValueWithType(value any, columnTypeName string) any {switch v := value.(type) {case nil:return nilcase []byte:return string(v)case time.Time:- return v.Format(time.RFC3339Nano)+ if isXuguTimezoneAwareTemporal(columnTypeName) {+ return v.Format("2006-01-02 15:04:05.999999999 -07:00")+ }+ return v.Format("2006-01-02 15:04:05.999999999")case int:return int64(v)case int8:@@ -6040,6 +6054,13 @@ func normalizeValue(value any) any {}}+// isXuguTimezoneAwareTemporal reports whether the column type carries a real+// timezone (…WITH TIME ZONE), so its formatted literal must keep the offset.+func isXuguTimezoneAwareTemporal(columnTypeName string) bool {+ normalized := strings.ToUpper(strings.TrimSpace(columnTypeName))+ return strings.Contains(normalized, "WITH TIME ZONE")+}+func emptyIfNil[T any](values []T) []T {if values == nil {return []T{}diff --git a/agents/drivers/xugu/main_test.go b/agents/drivers/xugu/main_test.goindex 74c19e7aea..ca14a42361 100644--- a/agents/drivers/xugu/main_test.go+++ b/agents/drivers/xugu/main_test.go@@ -3955,3 +3955,35 @@ func waitForXuguActiveOperation(t *testing.T, s *server) {}t.Fatal("operation did not become active")}++func TestNormalizeValueWithTypeFormatsXuguWritableTemporals(t *testing.T) {+ // XuguDB rejects the ISO "T"/"Z" literal that RFC3339Nano produces+ // (E19138 时间值常数错误), so temporal values must round-trip as a+ // space-separated wall-clock string. See issue #8110.+ loc := time.FixedZone("CST", 8*3600)+ instant := time.Date(2026, 6, 1, 19, 42, 21, 17_000_000, loc)++ cases := []struct {+ name string+ columnType string+ expected string+ }{+ {name: "datetime", columnType: "DATETIME", expected: "2026-06-01 19:42:21.017"},+ {name: "timestamp", columnType: "TIMESTAMP", expected: "2026-06-01 19:42:21.017"},+ {name: "date", columnType: "DATE", expected: "2026-06-01 19:42:21.017"},+ {name: "unknown type falls back to timezone-less", columnType: "", expected: "2026-06-01 19:42:21.017"},+ {name: "datetime with time zone keeps offset", columnType: "DATETIME WITH TIME ZONE", expected: "2026-06-01 19:42:21.017 +08:00"},+ {name: "timestamp with time zone keeps offset", columnType: "TIMESTAMP(6) WITH TIME ZONE", expected: "2026-06-01 19:42:21.017 +08:00"},+ }+ for _, tc := range cases {+ t.Run(tc.name, func(t *testing.T) {+ got := normalizeValueWithType(instant, tc.columnType)+ if got != tc.expected {+ t.Fatalf("normalizeValueWithType(%q) = %q, want %q", tc.columnType, got, tc.expected)+ }+ if str, ok := got.(string); ok && strings.ContainsAny(str, "TZ") {+ t.Fatalf("formatted temporal %q still contains an ISO T/Z literal Xugu rejects", str)+ }+ })+ }+}diff --git a/agents/drivers/xugu/spatial.go b/agents/drivers/xugu/spatial.goindex efc6982002..3caddd44b0 100644--- a/agents/drivers/xugu/spatial.go+++ b/agents/drivers/xugu/spatial.go@@ -123,7 +123,9 @@ func (decoder *xuguSpatialDecoder) normalizeRow(values []any) ([]any, []*uint32,}for index, value := range values {if !decoder.spatial[index] {- values[index] = normalizeValue(value)+ // Column types are known here, so temporal values format to a+ // Xugu-writable wall-clock string instead of an ISO "T"/"Z" literal.+ values[index] = normalizeValueWithType(value, decoder.columnTypes[index])}}if len(decoder.indices) > 0 {