fix(hana): allow empty database context
This commit is contained in:
parent
dafed47b07
commit
84e2093b82
|
|
@ -382,7 +382,7 @@ function completionCacheKey(table: { name: string; schema?: string | null }) {
|
|||
|
||||
async function ensureColumnsForTable(table: { name: string; schema?: string | null }) {
|
||||
const cacheKey = completionCacheKey(table);
|
||||
if (cachedColumnsByTable.has(cacheKey) || !props.connectionId || !props.database) return;
|
||||
if (cachedColumnsByTable.has(cacheKey) || !props.connectionId || props.database == null) return;
|
||||
const columns = await connectionStore.listCompletionColumns(
|
||||
props.connectionId,
|
||||
props.database,
|
||||
|
|
@ -453,7 +453,7 @@ function createSignatureDom(signature: ReturnType<typeof getSqlFunctionSignature
|
|||
}
|
||||
|
||||
async function resolveSqlHoverTooltip(currentView: EditorViewType, pos: number) {
|
||||
if (!props.connectionId || !props.database) return null;
|
||||
if (!props.connectionId || props.database == null) return null;
|
||||
|
||||
const sql = currentView.state.doc.toString();
|
||||
const range = identifierRangeAt(sql, pos);
|
||||
|
|
@ -582,7 +582,7 @@ function setSemanticDiagnostics(next: SqlSemanticDiagnostic[]) {
|
|||
}
|
||||
|
||||
async function enrichSemanticDiagnosticTables(tables: SqlTableReference[]) {
|
||||
if (!props.connectionId || !props.database) return tables;
|
||||
if (!props.connectionId || props.database == null) return tables;
|
||||
|
||||
const enriched: SqlTableReference[] = [];
|
||||
for (const table of tables) {
|
||||
|
|
@ -615,7 +615,7 @@ async function enrichSemanticDiagnosticTables(tables: SqlTableReference[]) {
|
|||
async function refreshSemanticDiagnostics() {
|
||||
const currentView = view.value;
|
||||
const runId = ++semanticDiagnosticRunId;
|
||||
if (!currentView || !props.connectionId || !props.database) {
|
||||
if (!currentView || !props.connectionId || props.database == null) {
|
||||
setSemanticDiagnostics([]);
|
||||
return;
|
||||
}
|
||||
|
|
@ -697,7 +697,7 @@ async function provideSqlCompletions(
|
|||
position: number,
|
||||
explicit: boolean,
|
||||
) {
|
||||
if (!props.connectionId || !props.database) return null;
|
||||
if (!props.connectionId || props.database == null) return null;
|
||||
|
||||
const epoch = ++completionEpoch;
|
||||
|
||||
|
|
@ -1254,7 +1254,7 @@ onMounted(async () => {
|
|||
if (event.button !== 0) return false;
|
||||
|
||||
const currentView = view.value;
|
||||
if (!currentView || !props.connectionId || !props.database) {
|
||||
if (!currentView || !props.connectionId || props.database == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -159,6 +159,10 @@ function currentDatabaseType(): DatabaseType | undefined {
|
|||
return props.node.connectionId ? connectionStore.getConfig(props.node.connectionId)?.db_type : undefined;
|
||||
}
|
||||
|
||||
function hasNodeDatabaseContext(node: TreeNode): node is TreeNode & { connectionId: string; database: string } {
|
||||
return !!node.connectionId && hasTreeNodeDatabaseContext(node);
|
||||
}
|
||||
|
||||
function getIconInfo(node: TreeNode): { icon: any; colorClass: string } | null {
|
||||
switch (node.type) {
|
||||
case "connection":
|
||||
|
|
@ -446,7 +450,7 @@ async function openObjectBrowser() {
|
|||
await connectionStore.ensureConnected(node.connectionId);
|
||||
connectionStore.activeConnectionId = node.connectionId;
|
||||
|
||||
if (node.database) {
|
||||
if (hasTreeNodeDatabaseContext(node)) {
|
||||
queryStore.openObjectBrowser(node.connectionId, node.database, node.schema);
|
||||
return;
|
||||
}
|
||||
|
|
@ -482,7 +486,7 @@ function openSavedSqlFile() {
|
|||
|
||||
async function openData() {
|
||||
const node = props.node;
|
||||
if (!(node.type === "table" || node.type === "view") || !node.connectionId || !node.database) return;
|
||||
if (!(node.type === "table" || node.type === "view") || !hasNodeDatabaseContext(node)) return;
|
||||
const config = connectionStore.getConfig(node.connectionId);
|
||||
const traceId = uuid().slice(0, 8);
|
||||
const startedAt = performance.now();
|
||||
|
|
@ -562,7 +566,7 @@ async function newQuery() {
|
|||
try {
|
||||
await connectionStore.ensureConnected(node.connectionId);
|
||||
connectionStore.activeConnectionId = node.connectionId;
|
||||
if (node.database) {
|
||||
if (hasTreeNodeDatabaseContext(node)) {
|
||||
queryStore.createTab(node.connectionId, node.database, undefined, "query", node.schema);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue