25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(editor): split Doris range partition statements
Eveaca3faa7621b
diff --git a/apps/desktop/src/lib/__tests__/sql/sqlStatementRanges.spec.ts b/apps/desktop/src/lib/__tests__/sql/sqlStatementRanges.spec.tsindex a54abbb9af..66602c8e6a 100644--- a/apps/desktop/src/lib/__tests__/sql/sqlStatementRanges.spec.ts+++ b/apps/desktop/src/lib/__tests__/sql/sqlStatementRanges.spec.ts@@ -1375,6 +1375,20 @@ FROM orders;`;});describe("executableStatementRanges", () => {+ 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,+ product_id int NULL+) ENGINE=OLAP+DUPLICATE KEY(sale_date, product_id)+PARTITION BY RANGE(sale_date) (+ PARTITION p_2024_01 VALUES [('2024-02-01'), ('2024-03-01'))+)+DISTRIBUTED BY HASH(product_id) BUCKETS 1`;+ const second = first.replace("fixed_partitions_1", "fixed_partitions_2");++ expect(rangeSqlTexts(executableStatementRanges(`${first};\n\n${second};`, databaseType))).toEqual([first, second]);+ });it("returns statement ranges starting only at statement starts", () => {const sql = "SELECT *\nFROM users\nWHERE active = 1;\nSELECT 2;";const ranges = executableStatementRanges(sql);diff --git a/apps/desktop/src/lib/sql/sqlStatementRanges.ts b/apps/desktop/src/lib/sql/sqlStatementRanges.tsindex 97f511cc36..10ddffc8c9 100644--- a/apps/desktop/src/lib/sql/sqlStatementRanges.ts+++ b/apps/desktop/src/lib/sql/sqlStatementRanges.ts@@ -196,6 +196,10 @@ function splitElasticsearchRestRequestRanges(sql: string): RawStatement[] | undetype QuoteState = "none" | "single" | "double" | "backtick" | "bracket" | "dollar";+function usesBracketIdentifierQuotes(databaseType?: DatabaseType): boolean {+ return databaseType !== "doris" && databaseType !== "starrocks";+}+const COMMON_SOFT_STATEMENT_START_KEYWORDS = ["SELECT","WITH",@@ -564,7 +568,7 @@ export function splitSqlStatementRanges(sql: string, databaseType?: DatabaseTypei += 1;continue;}- if (ch === "[") {+ if (ch === "[" && usesBracketIdentifierQuotes(databaseType)) {markContent(i);state = "bracket";i += 1;@@ -984,7 +988,7 @@ function topLevelSoftStatementLineStarts(sql: string, statement: RawStatement, di += 1;continue;}- if (ch === "[") {+ if (ch === "[" && usesBracketIdentifierQuotes(databaseType)) {state = "bracket";i += 1;continue;@@ -1187,7 +1191,7 @@ function topLevelWordsBefore(sql: string, from: number, to: number, limit: numbei += 1;continue;}- if (ch === "[") {+ if (ch === "[" && usesBracketIdentifierQuotes(databaseType)) {state = "bracket";i += 1;continue;@@ -1541,7 +1545,7 @@ function trimRangeEndBeforeNextBoundary(sql: string, from: number, nextBoundaryFi += 1;continue;}- if (ch === "[") {+ if (ch === "[" && usesBracketIdentifierQuotes(databaseType)) {state = "bracket";lastContentEnd = i + 1;i += 1;