Fix user_alter in postgresql_user

This commit is contained in:
Devin Christensen 2014-11-25 12:04:47 -07:00
parent c77ab67274
commit 06f1c1a97e

View file

@ -218,7 +218,7 @@ def user_alter(cursor, module, user, password, role_attr_flags, encrypted, expir
# Grab current role attributes. # Grab current role attributes.
current_role_attrs = cursor.fetchone() current_role_attrs = cursor.fetchone()
alter = ['ALTER USER "%(user)s"' % {"user": pg_quote_identifier(user, 'role')}] alter = ['ALTER USER %(user)s' % {"user": pg_quote_identifier(user, 'role')}]
if password is not None: if password is not None:
alter.append("WITH %(crypt)s" % {"crypt": encrypted}) alter.append("WITH %(crypt)s" % {"crypt": encrypted})
alter.append("PASSWORD %(password)s") alter.append("PASSWORD %(password)s")
@ -229,7 +229,7 @@ def user_alter(cursor, module, user, password, role_attr_flags, encrypted, expir
alter.append("VALID UNTIL %(expires)s") alter.append("VALID UNTIL %(expires)s")
try: try:
cursor.execute(alter, query_password_data) cursor.execute(' '.join(alter), query_password_data)
except psycopg2.InternalError, e: except psycopg2.InternalError, e:
if e.pgcode == '25006': if e.pgcode == '25006':
# Handle errors due to read-only transactions indicated by pgcode 25006 # Handle errors due to read-only transactions indicated by pgcode 25006