fix(editor): preserve SQL on full-width formatter errors

This commit is contained in:
Melody Ruch authored and GitHub committed 2026-08-12 19:26:16 +08:00
1 parent 463c3cd7f0
commit 2a26ea5429
2 files changed
+21 -1

No files matched your search

@@ -57,6 +57,13 @@ describe("sqlFormatter", () => {
await expect(formatSqlForEditing(sql, "mysql")).resolves.toBe(sql);
});
it("keeps editor SQL unchanged when it contains full-width characters the tokenizer can't parse", async () => {
const sql = "update t set a=concat(t.入池时间(审核通过时间),' 00:00:00') where t.入池时间(审核通过时间) ≠ '';";
await expect(formatSqlText(sql, "mysql")).rejects.toThrow("Parse error: Unexpected");
await expect(formatSqlForEditing(sql, "mysql")).resolves.toBe(sql);
});
it("keeps non-parse editor formatting failures visible", async () => {
const oversizedSql = "x".repeat(MAX_SQL_FORMAT_CHARS + 1);