fix(editor): validate MyBatis statement placeholders
This commit is contained in:
7 files changed
+141
-74
No files matched your search
@@ -27,6 +27,25 @@ describe("executableStatementRangeCacheForDoc", () => {
|
||||
expect(executableStatementRangeStartingAt(cache, secondStatementLine.from)?.sql).toBe("SELECT *\nFROM menus AS mn\nLIMIT 100");
|
||||
});
|
||||
|
||||
it("keeps MyBatis parameters in a Kingbase gutter execution range", () => {
|
||||
const sql = ["SELECT sum(nvl(a.medfee_sumamt, 0)) AS medfee_sumamt, a.insutype", "FROM yd_org_decla_detail a", "WHERE a.busin_type = '1' AND a.clr_ym = #{ym}", "GROUP BY a.clr_ym, a.insutype;"].join("\n");
|
||||
const doc = Text.of(sql.split("\n"));
|
||||
const cache = executableStatementRangeCacheForDoc(null, doc, "kingbase");
|
||||
|
||||
expect(executableStatementRangeStartingAt(cache, doc.line(1).from)?.sql).toBe(sql.slice(0, -1));
|
||||
});
|
||||
|
||||
it("keeps a valid placeholder-only line executable and respects disabled MyBatis syntax", () => {
|
||||
const sql = ["SELECT *", "FROM t", "#{where_clause};"].join("\n");
|
||||
const doc = Text.of(sql.split("\n"));
|
||||
const enabled = executableStatementRangeCacheForDoc(null, doc, "kingbase", { enabledSyntaxes: ["mybatis"] });
|
||||
const disabled = executableStatementRangeCacheForDoc(enabled, doc, "kingbase", { enabledSyntaxes: ["shell"] });
|
||||
|
||||
expect(executableStatementRangeAtCursor(enabled, doc.line(3).from + 2)?.sql).toBe(sql.slice(0, -1));
|
||||
expect(executableStatementRangeAtCursor(disabled, doc.line(3).from + 2)).toBeNull();
|
||||
expect(disabled).not.toBe(enabled);
|
||||
});
|
||||
|
||||
it("resolves statements with leading whitespace for gutter run buttons", () => {
|
||||
const doc = Text.of([" SELECT 1;", " SELECT 2;", "\t SELECT 3;", "", " "]);
|
||||
const cache = executableStatementRangeCacheForDoc(null, doc, "mysql");
|
||||
|
||||
Reference in new issue
Block a user