fix: correct CAST completion signature

This commit is contained in:
Spencer.Chang 2026-06-25 23:35:21 +08:00 committed by GitHub
parent 49bb28ecf0
commit 8ac0038ad7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View File

@ -786,7 +786,7 @@ const SQL_FUNCTION_SIGNATURES = new Map<string, string[]>([
["COALESCE", ["value", "...values"]],
["IFNULL", ["expression", "fallback"]],
["NULLIF", ["expression1", "expression2"]],
["CAST", ["expression", "type"]],
["CAST", ["expression AS type"]],
["CONVERT", ["expression", "type"]],
["GREATEST", ["...values"]],
["LEAST", ["...values"]],

View File

@ -974,6 +974,18 @@ test("returns function signature help inside function arguments", () => {
});
});
test("returns cast signature with AS syntax", () => {
const sql = "select cast(created_at ";
const signature = getSqlFunctionSignatureHelp(sql, sql.length);
assert.deepEqual(signature, {
name: "CAST",
signature: "CAST(expression AS type)",
activeParameter: 0,
parameters: ["expression AS type"],
});
});
test("returns null signature help outside function calls", () => {
assert.equal(getSqlFunctionSignatureHelp("select created_at from users", "select created_at".length), null);
});