File tree Expand file tree Collapse file tree 1 file changed +7
-18
lines changed Expand file tree Collapse file tree 1 file changed +7
-18
lines changed Original file line number Diff line number Diff line change 1
1
import { ident , literal } from 'pg-format'
2
- import { DEFAULT_ROLES , DEFAULT_SYSTEM_SCHEMAS } from './constants'
3
- import { coalesceRowsToArray } from './helpers'
4
- import { grantsSql , rolesSql } from './sql'
2
+ import { DEFAULT_ROLES } from './constants'
3
+ import { rolesSql } from './sql'
5
4
import { PostgresMetaResult , PostgresRole } from './types'
6
5
7
6
export default class PostgresMetaRoles {
@@ -13,31 +12,21 @@ export default class PostgresMetaRoles {
13
12
14
13
async list ( {
15
14
includeDefaultRoles = false ,
16
- includeSystemSchemas = false ,
17
15
limit,
18
16
offset,
19
17
} : {
20
18
includeDefaultRoles ?: boolean
21
- includeSystemSchemas ?: boolean
22
19
limit ?: number
23
20
offset ?: number
24
21
} = { } ) : Promise < PostgresMetaResult < PostgresRole [ ] > > {
25
22
let sql = `
26
- WITH roles AS (${
27
- includeDefaultRoles
28
- ? rolesSql
29
- : `${ rolesSql } WHERE NOT (rolname IN (${ DEFAULT_ROLES . map ( literal ) . join ( ',' ) } ))`
30
- } ),
31
- grants AS (${
32
- includeSystemSchemas
33
- ? grantsSql
34
- : `${ grantsSql } AND NOT (nc.nspname IN (${ DEFAULT_SYSTEM_SCHEMAS . map ( literal ) . join ( ',' ) } ))`
35
- } )
23
+ WITH
24
+ roles AS (${ rolesSql } )
36
25
SELECT
37
- *,
38
- ${ coalesceRowsToArray ( 'grants' , 'grants.grantee = roles.name' ) }
26
+ *
39
27
FROM
40
- roles`
28
+ roles
29
+ ${ includeDefaultRoles ? '' : `WHERE name NOT IN (${ DEFAULT_ROLES . map ( literal ) . join ( ',' ) } )` } `
41
30
if ( limit ) {
42
31
sql = `${ sql } LIMIT ${ limit } `
43
32
}
You can’t perform that action at this time.
0 commit comments