()
| 30 | } |
| 31 | |
| 32 | public async getChildren(): Promise<INode[]> { |
| 33 | const connection = await Database.createConnection(this.connection); |
| 34 | const configVirtFolders = Global.Configuration.get<Array<string>>("virtualFolders"); |
| 35 | |
| 36 | try { |
| 37 | const res = await connection.query(` |
| 38 | SELECT |
| 39 | c.relname as "name", |
| 40 | (c.relkind IN ('r', 'f')) as is_table, |
| 41 | (c.relkind = 'f') as is_foreign, |
| 42 | n.nspname as "schema" |
| 43 | FROM |
| 44 | pg_catalog.pg_class c |
| 45 | JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace |
| 46 | WHERE |
| 47 | c.relkind in ('r', 'v', 'm', 'f') |
| 48 | AND n.nspname = $1 |
| 49 | AND has_table_privilege(quote_ident(n.nspname) || '.' || quote_ident(c.relname), 'SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER') = true |
| 50 | ORDER BY |
| 51 | c.relname;`, [this.schemaName]); |
| 52 | |
| 53 | let childs = []; |
| 54 | if (configVirtFolders != null) |
| 55 | { |
| 56 | if (configVirtFolders.indexOf("functions") !== -1) { |
| 57 | childs.push(new FunctionFolderNode(this.connection, this.schemaName)); |
| 58 | } |
| 59 | } |
| 60 | // Append tables under virtual folders |
| 61 | return childs.concat(res.rows.map<TableNode>(table => { |
| 62 | return new TableNode( |
| 63 | this.connection, |
| 64 | table.name, |
| 65 | table.is_table, |
| 66 | table.is_foreign, |
| 67 | table.schema |
| 68 | ); |
| 69 | })); |
| 70 | } catch(err) { |
| 71 | return [new InfoNode(err)]; |
| 72 | } finally { |
| 73 | await connection.end(); |
| 74 | } |
| 75 | } |
| 76 | } |
nothing calls this directly
no test coverage detected