File tree Expand file tree Collapse file tree 3 files changed +11
-23
lines changed
Expand file tree Collapse file tree 3 files changed +11
-23
lines changed Original file line number Diff line number Diff line change @@ -36,8 +36,11 @@ import dayjs from 'dayjs';
3636async function getDefaultSchema ( dsId : number , userName : string ) {
3737 const res = await listDatabases ( null , dsId , 1 , 999 ) ;
3838 const databases = res ?. contents ;
39+ // mysql 模式的默认数据库是 information_schema
3940 const informationSchema = databases ?. find ( ( d ) => d . name === 'information_schema' ) ;
41+ // oracle 模式的的默认数据库是和用户名相同的 schema
4042 const sameName = databases ?. find ( ( d ) => d . name ?. toLowerCase ( ) === userName ?. toLowerCase ( ) ) ;
43+ // 如果都没有,则取第一个
4144 return informationSchema ?. id || sameName ?. id || databases ?. [ 0 ] ?. id ;
4245}
4346
@@ -197,7 +200,6 @@ export const action = async (config: ICustomConnectAction) => {
197200 return 'Connection Test Failed' ;
198201 }
199202 const createResult = await newConnection ( params ) ;
200- const databaseName = params ?. defaultSchema ;
201203
202204 if ( createResult ) {
203205 gotoSQLWorkspace (
@@ -208,7 +210,6 @@ export const action = async (config: ICustomConnectAction) => {
208210 generateUniqKey ( ) ,
209211 false ,
210212 false ,
211- databaseName ,
212213 ) ;
213214 } else {
214215 return 'create connection failed' ;
Original file line number Diff line number Diff line change @@ -59,25 +59,13 @@ export default inject(
5959 }
6060
6161 const resolveParams = async ( ) => {
62- const databaseName = searchParams . get ( 'databaseName' ) ;
63- if ( tempDatasourceId ) {
64- const databaseListData =
65- resourcetreeContext . databaseList ?. length > 0
66- ? resourcetreeContext . databaseList
67- : await resourcetreeContext . reloadDatabaseList ( ) ;
68- if ( databaseName && databaseListData ) {
69- const targetDatabase = databaseListData . find (
70- ( db ) => db . name === databaseName && db ?. dataSource ?. id === parseInt ( tempDatasourceId ) ,
71- ) ;
72- if ( targetDatabase ) {
73- // 打开sql窗口
74- openNewSQLPage ( targetDatabase . id ) ;
75- // 删除databaseName参数
76- const newSearchParams = new URLSearchParams ( searchParams ) ;
77- newSearchParams . delete ( 'databaseName' ) ;
78- setSearchParams ( newSearchParams , { replace : true } ) ;
79- }
80- }
62+ const databaseId = searchParams . get ( 'databaseId' ) ;
63+ if ( databaseId ) {
64+ // 打开sql窗口
65+ openNewSQLPage ( parseInt ( databaseId ) ) ;
66+ const newSearchParams = new URLSearchParams ( searchParams ) ;
67+ newSearchParams . delete ( 'databaseId' ) ;
68+ setSearchParams ( newSearchParams , { replace : true } ) ;
8169 }
8270 } ;
8371
Original file line number Diff line number Diff line change @@ -24,13 +24,12 @@ export function gotoSQLWorkspace(
2424 tabKey : string = '' ,
2525 isLogicalDatabase : boolean = false ,
2626 isCreateTable : boolean = false ,
27- databaseName ?: string ,
2827) {
2928 const url =
3029 location . origin +
3130 location . pathname +
3231 ( tabKey
33- ? `#/sqlworkspace/${ tabKey } /${ datasourceId } ?databaseName =${ databaseName } `
32+ ? `#/sqlworkspace/${ tabKey } /${ datasourceId } ?databaseId =${ databaseId } `
3433 : `#/sqlworkspace?projectId=${ projectId || '' } &datasourceId=${
3534 datasourceId || ''
3635 } &databaseId=${
You can’t perform that action at this time.
0 commit comments