mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 13:06:01 +00:00
default schema refactor
This commit is contained in:
15
packages/tools/src/schemaInfoTools.ts
Normal file
15
packages/tools/src/schemaInfoTools.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { SchemaInfo, SqlDialect } from 'dbgate-types';
|
||||
|
||||
export function findDefaultSchema(schemaList: SchemaInfo[], dialect: SqlDialect) {
|
||||
if (!schemaList) {
|
||||
return null;
|
||||
}
|
||||
const dynamicDefaultSchema = schemaList.find(x => x.isDefault);
|
||||
if (dynamicDefaultSchema) {
|
||||
return dynamicDefaultSchema.schemaName;
|
||||
}
|
||||
if (dialect.defaultSchemaName && schemaList.find(x => x.schemaName == dialect.defaultSchemaName)) {
|
||||
return dialect.defaultSchemaName;
|
||||
}
|
||||
return schemaList[0]?.schemaName;
|
||||
}
|
||||
Reference in New Issue
Block a user