Browse Source

Merge pull request #5870 from nocodb/fix/5823-filter-views-based-on-active-schema

fix: Filter view list based on current schema in pg and mssql
pull/5890/head
mertmit 1 year ago committed by GitHub
parent
commit
60f2cc6f32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      packages/nocodb/src/db/sql-client/lib/mssql/MssqlClient.ts
  2. 3
      packages/nocodb/src/db/sql-client/lib/pg/PgClient.ts

3
packages/nocodb/src/db/sql-client/lib/mssql/MssqlClient.ts

@ -1118,8 +1118,9 @@ class MssqlClient extends KnexClient {
args.databaseName = this.connectionConfig.connection.database; args.databaseName = this.connectionConfig.connection.database;
const response = await this.sqlClient.raw( const response = await this.sqlClient.raw(
`SELECT v.name AS view_name,v.*,m.* FROM sys.views v INNER JOIN sys.schemas s ON s.schema_id = v.schema_id `SELECT v.name AS view_name,v.*,m.* FROM sys.views v INNER JOIN sys.schemas s ON s.schema_id = v.schema_id AND schema_name(v.schema_id) = ?
INNER JOIN sys.sql_modules AS m ON m.object_id = v.object_id`, INNER JOIN sys.sql_modules AS m ON m.object_id = v.object_id`,
[this.schema || 'dbo'],
); );
result.data.list = response; result.data.list = response;

3
packages/nocodb/src/db/sql-client/lib/pg/PgClient.ts

@ -1350,7 +1350,8 @@ class PGClient extends KnexClient {
const { rows } = await this.sqlClient.raw( const { rows } = await this.sqlClient.raw(
`select * `select *
from INFORMATION_SCHEMA.views from INFORMATION_SCHEMA.views
WHERE table_schema = ANY (current_schemas(false));`, WHERE table_schema = ?;`,
[this.schema],
); );
for (let i = 0; i < rows.length; ++i) { for (let i = 0; i < rows.length; ++i) {

Loading…
Cancel
Save