fix(mysql): complete built-in function suggestions

Closes #6846
This commit is contained in:
t8y2 committed 2026-08-21 04:09:56 +00:00
1 parent ec50662793
commit c210efbcc5
4 files changed
+204 -2

No files matched your search

@@ -1035,6 +1035,22 @@ WHERE request_json LIKE '%"paperFlag":null%';`;
expect(rangeSqlTexts(executableStatementRanges(sql, "mysql"))).toEqual([sql.slice(0, -1)]);
});
it("keeps a line-start MySQL TRUNCATE function inside a SELECT projection", () => {
const sql = `SELECT
order_id,
TRUNCATE(amount, 2) AS rounded_amount
FROM orders;`;
expect(rangeSqlTexts(executableStatementRanges(sql, "mysql"))).toEqual([sql.slice(0, -1)]);
expect(currentExecutableStatementRange(sql, indexOf(sql, "TRUNCATE"), "mysql")?.sql.trim()).toBe(sql.slice(0, -1));
});
it("keeps standalone TRUNCATE TABLE statements separate", () => {
const sql = "SELECT 1;\nTRUNCATE TABLE t;";
expect(rangeSqlTexts(executableStatementRanges(sql, "mysql"))).toEqual(["SELECT 1", "TRUNCATE TABLE t"]);
});
it("does not merge a plain MySQL DESC table statement with the next query", () => {
const sql = "DESC users\nSELECT * FROM users;";
expect(statementRangeAtCursor(sql, indexOf(sql, "DESC"), "mysql")?.sql.trim()).toBe("DESC users");