fix(grid): parse ambiguous comma numbers by locale

This commit is contained in:
Guoyu Su authored and GitHub committed 2026-08-31 16:54:47 +08:00
1 parent 99c3bd0f42
commit 27f62fe6e2
2 files changed
+75 -18

No files matched your search

@@ -250,15 +250,36 @@ describe("coerceDataGridCellValue", () => {
).toBe("9007199254740993");
});
it("leaves ambiguous single-group values untouched", () => {
it("normalizes ambiguous single-comma values using the runtime number format", () => {
expect(
coerceDataGridCellValue({
value: "10,000",
oldValue: 10000,
databaseType: "sqlserver",
columnInfo: { data_type: "int" },
oldValue: "0.0000",
databaseType: "mysql",
columnInfo: { data_type: "decimal(14,4)" },
numberFormat: { groupSeparator: ",", decimalSeparator: "." },
}),
).toBe("10,000");
).toBe("10000");
expect(
coerceDataGridCellValue({
value: "114,870",
oldValue: "0.0000",
databaseType: "mysql",
columnInfo: { data_type: "decimal(14,4)" },
numberFormat: { groupSeparator: ",", decimalSeparator: "." },
}),
).toBe("114870");
expect(
coerceDataGridCellValue({
value: "114,870",
oldValue: "0.0000",
databaseType: "mysql",
columnInfo: { data_type: "decimal(14,4)" },
numberFormat: { groupSeparator: ".", decimalSeparator: "," },
}),
).toBe("114.870");
expect(
coerceDataGridCellValue({
@@ -266,8 +287,21 @@ describe("coerceDataGridCellValue", () => {
oldValue: 1000000,
databaseType: "sqlserver",
columnInfo: { data_type: "float" },
numberFormat: { groupSeparator: ".", decimalSeparator: "," },
}),
).toBe("1,000e3");
).toBe(1000);
});
it("leaves ambiguous comma values untouched when the runtime format uses neither comma token", () => {
expect(
coerceDataGridCellValue({
value: "10,000",
oldValue: 10000,
databaseType: "sqlserver",
columnInfo: { data_type: "int" },
numberFormat: { groupSeparator: "’", decimalSeparator: "." },
}),
).toBe("10,000");
});
it("does not strip commas when the column is not numeric", () => {