1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Select all fields from the user, as some of them are version-dependent

This commit is contained in:
Daniel Hokka Zakrisson 2012-12-05 09:51:15 +01:00
parent 65413dc778
commit 11b64314df

View file

@ -146,14 +146,9 @@ def user_alter(cursor, user, password, role_attr_flags):
# Handle passwords. # Handle passwords.
if password is not None or role_attr_flags is not None: if password is not None or role_attr_flags is not None:
# Define columns for select.
columns = 'rolpassword,rolsuper,rolinherit,rolcreaterole,rolcreatedb,rolcanlogin,rolreplication'
# Select password and all flag-like columns in order to verify changes. # Select password and all flag-like columns in order to verify changes.
# rolsuper | rolinherit | rolcreaterole | rolcreatedb | rolcatupdate | select = "SELECT * FROM pg_authid where rolname=%(user)s"
# rolcanlogin | rolreplication | rolconnlimit | rolpassword | rolvaliduntil cursor.execute(select, {"user": user})
# Not sure how to interpolate properly in python yet...
select = "SELECT " + columns + " FROM pg_authid where rolname=%(user)s"
cursor.execute(select, {"columns": columns, "user": user})
# Grab current role attributes. # Grab current role attributes.
current_role_attrs = cursor.fetchone() current_role_attrs = cursor.fetchone()
@ -166,7 +161,7 @@ def user_alter(cursor, user, password, role_attr_flags):
alter = "ALTER USER %(user)s WITH %(role_attr_flags)s" alter = "ALTER USER %(user)s WITH %(role_attr_flags)s"
cursor.execute(alter % {"user": user, "role_attr_flags": role_attr_flags}) cursor.execute(alter % {"user": user, "role_attr_flags": role_attr_flags})
# Grab new role attributes. # Grab new role attributes.
cursor.execute(select, {"columns": columns, "user": user}) cursor.execute(select, {"user": user})
new_role_attrs = cursor.fetchone() new_role_attrs = cursor.fetchone()
# Detect any differences between current_ and new_role_attrs. # Detect any differences between current_ and new_role_attrs.