mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-27 14:56:00 +00:00
default schema refactor
This commit is contained in:
@@ -92,8 +92,6 @@ class MsSqlAnalyser extends DatabaseAnalyser {
|
||||
const indexesRows = await this.analyserQuery('indexes', ['tables']);
|
||||
this.feedback({ analysingMessage: 'Loading index columns' });
|
||||
const indexcolsRows = await this.analyserQuery('indexcols', ['tables']);
|
||||
this.feedback({ analysingMessage: 'Loading default schema' });
|
||||
const defaultSchemaRows = await this.driver.query(this.pool, 'SELECT SCHEMA_NAME() as name');
|
||||
this.feedback({ analysingMessage: 'Loading table sizes' });
|
||||
const tableSizes = await this.analyserQuery('tableSizes');
|
||||
|
||||
@@ -173,7 +171,6 @@ class MsSqlAnalyser extends DatabaseAnalyser {
|
||||
views,
|
||||
procedures,
|
||||
functions,
|
||||
defaultSchema: defaultSchemaRows.rows[0] ? defaultSchemaRows.rows[0].name : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,14 @@ const driver = {
|
||||
},
|
||||
async listSchemas(pool) {
|
||||
const { rows } = await this.query(pool, 'select schema_id as objectId, name as schemaName from sys.schemas');
|
||||
return rows;
|
||||
|
||||
const defaultSchemaRows = await this.query(pool, 'SELECT SCHEMA_NAME() as name');
|
||||
const defaultSchema = defaultSchemaRows.rows[0]?.name;
|
||||
|
||||
return rows.map(x => ({
|
||||
...x,
|
||||
isDefault: x.schemaName == defaultSchema,
|
||||
}));
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -273,10 +273,13 @@ const drivers = driverBases.map(driverBase => ({
|
||||
pool,
|
||||
'select oid as "object_id", nspname as "schema_name" from pg_catalog.pg_namespace'
|
||||
);
|
||||
const defaultSchemaRows = await this.query(pool, 'SHOW SEARCH_PATH;');
|
||||
const searchPath = defaultSchemaRows.rows[0]?.search_path?.replace('"$user",', '')?.trim();
|
||||
|
||||
const schemas = schemaRows.rows.map(x => ({
|
||||
schemaName: x.schema_name,
|
||||
objectId: x.object_id,
|
||||
isDefault: x.schema_name == searchPath,
|
||||
}));
|
||||
|
||||
return schemas;
|
||||
|
||||
Reference in New Issue
Block a user