MCPcopy Create free account
hub / github.com/bytebase/bytebase / isConnectedSQLEditorTab

Function isConnectedSQLEditorTab

frontend/src/react/lib/sqlEditorConnection.ts:40–54  ·  view source on GitHub ↗
(tab: SQLEditorTab)

Source from the content-addressed store, hash-verified

38};
39
40export const isConnectedSQLEditorTab = (tab: SQLEditorTab): boolean => {
41 const { instance, database } = getConnectionForSQLEditorTab(tab);
42 if (!instance) {
43 return false;
44 }
45 if (!isValidInstanceName(instance.name)) {
46 return false;
47 }
48
49 if (instanceV1AllowsCrossDatabaseQuery(instance)) {
50 // Connecting to instance directly.
51 return true;
52 }
53 return !!database && isValidDatabaseName(database.name);
54};
55
56/**
57 * Resolves the connection record for a worksheet by hydrating its database

Callers 3

SheetConnectionIconFunction · 0.90
useIsDisconnectedFunction · 0.90
useExecuteSQLFunction · 0.90

Calls 4

isValidInstanceNameFunction · 0.90
isValidDatabaseNameFunction · 0.90

Tested by

no test coverage detected