postgres.PgMembership: use query params in cursor.execute method (#65164)

* postgres.PgMembership: use query params in cursor.execute method

* changelog fragment
This commit is contained in:
Andrey Klychkov 2019-11-26 14:19:41 +03:00 committed by John R Barker
parent 2242c385b2
commit f543e72d0a
2 changed files with 4 additions and 2 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- postgres - use query params with cursor.execute in module_utils.postgres.PgMembership class (https://github.com/ansible/ansible/pull/65164).

View file

@ -276,9 +276,9 @@ class PgMembership(object):
"JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) "
"WHERE m.member = r.oid) "
"FROM pg_catalog.pg_roles r "
"WHERE r.rolname = '%s'" % dst_role)
"WHERE r.rolname = %(dst_role)s")
res = exec_sql(self, query, add_to_executed=False)
res = exec_sql(self, query, query_params={'dst_role': dst_role}, add_to_executed=False)
membership = []
if res:
membership = res[0][0]