mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 03:53:57 +00:00
postgres - user current_schema instead of search_path
This commit is contained in:
@@ -277,15 +277,15 @@ const drivers = driverBases.map(driverBase => ({
|
|||||||
dbhan,
|
dbhan,
|
||||||
'select oid as "object_id", nspname as "schema_name" from pg_catalog.pg_namespace'
|
'select oid as "object_id", nspname as "schema_name" from pg_catalog.pg_namespace'
|
||||||
);
|
);
|
||||||
const defaultSchemaRows = await this.query(dbhan, 'SHOW SEARCH_PATH;');
|
const defaultSchemaRows = await this.query(dbhan, 'SELECT current_schema');
|
||||||
const searchPath = defaultSchemaRows.rows[0]?.search_path?.replace('"$user",', '')?.trim();
|
const defaultSchema = defaultSchemaRows.rows[0]?.current_schema?.trim();
|
||||||
|
|
||||||
logger.debug(`Loaded ${schemaRows.rows.length} postgres schemas`);
|
logger.debug(`Loaded ${schemaRows.rows.length} postgres schemas`);
|
||||||
|
|
||||||
const schemas = schemaRows.rows.map(x => ({
|
const schemas = schemaRows.rows.map(x => ({
|
||||||
schemaName: x.schema_name,
|
schemaName: x.schema_name,
|
||||||
objectId: x.object_id,
|
objectId: x.object_id,
|
||||||
isDefault: x.schema_name == searchPath,
|
isDefault: x.schema_name == defaultSchema,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return schemas;
|
return schemas;
|
||||||
|
|||||||
Reference in New Issue
Block a user