fix(iris): disable bracket identifier scanning in ranges

This commit is contained in:
zipg
2026-10-01 22:33:14 +08:00
committed by GitHub
parent af9fa80070
commit b6049d80d0
6 changed files with 32 additions and 1 deletions
+2
View File
@@ -68,6 +68,8 @@ jobs:
runs-on: ubuntu-24.04
env:
NPM_CONFIG_LOGLEVEL: error
# Cold vue-tsc runs exceed 4 GiB; public Linux runners provide 16 GiB RAM.
NODE_OPTIONS: --max-old-space-size=8192
steps:
- uses: actions/checkout@v7
@@ -79,6 +79,20 @@ function keydown(target: HTMLElement, key: string) {
}
describe("QueryEditor component split integration", () => {
it("executes each IRIS query separately after the Contains operator", async () => {
const first = "select * from oec_order_adminstatus where STAT_Code [ '123'";
const second = "select top 10 * from Ens_HOSDocument";
const source = first + "\n\n" + second;
const { editor, view, onExecute } = await mountEditor({ modelValue: source, databaseType: "iris", dialect: "postgres" });
view.dispatch({ selection: { anchor: source.indexOf(second) + 7 } });
expect(editor.requestExecute({ bypassPicker: true })).toBe(true);
expect(onExecute.mock.lastCall?.[0].selectedSql).toBe(second);
view.dispatch({ selection: { anchor: 7 } });
expect(editor.requestExecute({ bypassPicker: true })).toBe(true);
expect(onExecute.mock.lastCall?.[0].selectedSql).toBe(first);
});
it("preserves upstream structure-peek focus and insertion context across updates and unmount", async () => {
const { view, props, unmount } = await mountEditor({ connectionId: "peek-a", database: "demo", schema: "public" });
expect(queryEditorInsertContext(view)).toEqual({ connectionId: "peek-a", database: "demo", schema: "public", databaseType: "mysql" });
@@ -1684,6 +1684,20 @@ SET t.no = s.no`;
});
describe("executableStatementRanges", () => {
it.each(["\n\n", ";\n", "; "])("keeps SELECT after an IRIS Contains operator separate with separator %j", (separator) => {
const first = "select * from oec_order_adminstatus where STAT_Code [ '123'";
const second = "select top 10 * from Ens_HOSDocument";
const sql = first + separator + second;
expect(rangeSqlTexts(executableStatementRanges(sql, "iris"))).toEqual([first, second]);
expect(currentExecutableStatementRange(sql, sql.indexOf(second) + 7, "iris")?.sql).toBe(second);
});
it("keeps SQL Server bracket identifiers containing semicolons quoted", () => {
const sql = "SELECT [name;part] FROM [table;part]; SELECT 2;";
expect(rangeSqlTexts(executableStatementRanges(sql, "sqlserver"))).toEqual(["SELECT [name;part] FROM [table;part]", "SELECT 2"]);
});
it.each(["doris", "starrocks"] as const)("keeps %s half-open range partitions from swallowing the next statement", (databaseType) => {
const first = `CREATE TABLE fixed_partitions_1 (
sale_date date NULL,
@@ -214,7 +214,8 @@ function splitElasticsearchRestRequestRanges(sql: string): RawStatement[] | unde
type QuoteState = "none" | "single" | "double" | "backtick" | "bracket" | "dollar";
function usesBracketIdentifierQuotes(databaseType?: DatabaseType): boolean {
return databaseType !== "doris" && databaseType !== "starrocks";
// IRIS uses `[` as its Contains operator, with no matching `]`.
return databaseType !== "doris" && databaseType !== "starrocks" && databaseType !== "iris";
}
const COMMON_SOFT_STATEMENT_START_KEYWORDS = [
Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB