Skip to content
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

Enhance PostgreSQL role management by adding ALTER ROLE support #1318

Open
wants to merge 3 commits into
base: 3.x
Choose a base branch
from

Conversation

wowi42
Copy link
Contributor

@wowi42 wowi42 commented Mar 24, 2025

Updated the role function to yield SQL commands for altering existing PostgreSQL roles, allowing modifications to attributes such as LOGIN, SUPERUSER, and CONNECTION LIMIT. Changed the parameter name for sudo_user to _sudo_user for consistency.

wowi42 added 2 commits March 24, 2025 18:07
Updated the role function to yield SQL commands for altering existing PostgreSQL roles, allowing modifications to attributes such as LOGIN, SUPERUSER, and CONNECTION LIMIT. Changed the parameter name for sudo_user to _sudo_user for consistency.
…ing role update test

Deleted the role_add_noop.json file as it was no longer needed. Introduced role_update.json to test the ALTER ROLE functionality, including connection limit and password updates for the 'testuser' role.
Copy link
Member

@Fizzadar Fizzadar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm, it'd be nice to not make every postgres.role operation execute a command every time, could we check the existing role to see if ALTER is needed?

I think if a password is set we'll always need to alter because we can't check those, but all the other arguments should be the relevant info on the roles fact.

@wowi42
Copy link
Contributor Author

wowi42 commented Mar 27, 2025

Correct, I will work on it

Updated the role function to check if any attributes (LOGIN, SUPERUSER, INHERIT, CREATEDB, CREATEROLE, CONNECTION LIMIT, PASSWORD) need to be altered before executing the SQL command. Added a new test case to verify the no-op behavior when the role already exists with the specified attributes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants