feat(query): pin, rename and label result run tabs
This commit is contained in:
26 files changed
+319
-32
No files matched your search
@@ -29,7 +29,18 @@ function firstSourceOfKind(sources: SqlSemanticRowSource[], kind: SqlSemanticRow
|
||||
return sources.filter((source) => source.kind === kind).sort((left, right) => left.sourceSpan.start - right.sourceSpan.start)[0];
|
||||
}
|
||||
|
||||
export function queryResultSourceLabel(sql: string, options: QueryResultSourceLabelOptions = {}): string | undefined {
|
||||
export interface QueryResultSourceNameParts {
|
||||
/** 库名 / schema 等限定名;SQL 未显式限定时由当前库补齐 */
|
||||
qualifier?: string;
|
||||
/** 表名或写入目标对象名 */
|
||||
name: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析结果集来源的限定名与对象名。结果集页签需要按设置决定是否展示限定名,
|
||||
* 而库名本身可能包含点(例如 `cosimulation2.0`),所以不能对拼好的标签做字符串切割。
|
||||
*/
|
||||
export function queryResultSourceNameParts(sql: string, options: QueryResultSourceLabelOptions = {}): QueryResultSourceNameParts | undefined {
|
||||
const statement = sql.trim();
|
||||
if (!statement) return undefined;
|
||||
|
||||
@@ -38,5 +49,11 @@ export function queryResultSourceLabel(sql: string, options: QueryResultSourceLa
|
||||
if (!source?.name) return undefined;
|
||||
|
||||
const qualifier = source.qualifierParts[source.qualifierParts.length - 1]?.trim() || options.database?.trim();
|
||||
return qualifier ? `${qualifier}.${source.name}` : source.name;
|
||||
return { qualifier: qualifier || undefined, name: source.name };
|
||||
}
|
||||
|
||||
export function queryResultSourceLabel(sql: string, options: QueryResultSourceLabelOptions = {}): string | undefined {
|
||||
const parts = queryResultSourceNameParts(sql, options);
|
||||
if (!parts) return undefined;
|
||||
return parts.qualifier ? `${parts.qualifier}.${parts.name}` : parts.name;
|
||||
}
|
||||
Reference in new issue
Block a user