8000 fix: Fix logic when returning default roles by ruggi99 · Pull Request #490 · supabase/postgres-meta · GitHub
[go: up one dir, main page]

Skip to content

fix: Fix logic when returning default roles #490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: replace DEFAULT_ROLES w/ prefix test
  • Loading branch information
soedirgo committed Jan 30, 2023
commit fc59610ea74ab83a84935fad06320ca93a74ba89
11 changes: 9 additions & 2 deletions src/lib/PostgresMetaRoles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ident, literal } from 'pg-format'
import { DEFAULT_ROLES } from './constants.js'
import { rolesSql } from './sql/index.js'
import {
PostgresMetaResult,
Expand Down Expand Up @@ -43,7 +42,15 @@ FROM
WHERE
true`
if (!includeDefaultRoles) {
sql += ` AND name NOT IN (${DEFAULT_ROLES.map(literal).join(',')})`
// All default/predefined roles start with pg_: https://www.postgresql.org/docs/15/predefined-roles.html
// The pg_ prefix is also reserved:
//
// ```
// postgres=# create role pg_mytmp;
// ERROR: role name "pg_mytmp" is reserved
// DETAIL: Role names starting with "pg_" are reserved.
// ```
sql += ` AND NOT pg_catalog.starts_with(name, 'pg_')`
}
if (limit) {
sql += ` LIMIT ${limit}`
Expand Down
11 changes: 0 additions & 11 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
export const DEFAULT_ROLES = [
'pg_execute_server_program',
'pg_monitor',
'pg_read_all_settings',
'pg_read_all_stats',
'pg_read_server_files',
'pg_signal_backend',
'pg_stat_scan_tables',
'pg_write_server_files',
]

export const DEFAULT_SYSTEM_SCHEMAS = [
'information_schema',
'pg_catalog',
Expand Down
0