postgresql_publication: use query params with cursor object (#65404)

* postgresql_publication: use query params with cursor object

* add changelog
This commit is contained in:
Andrey Klychkov 2019-12-05 13:44:45 +03:00 committed by John R Barker
parent 0c71249b03
commit 8f78a0f8bf
3 changed files with 10 additions and 5 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- postgresql_publication - use query params arg with cursor object (https://github.com/ansible/ansible/issues/65404).

View file

@ -431,15 +431,15 @@ class PgPublication():
"p.pubupdate , p.pubdelete, p.pubtruncate FROM pg_publication AS p " "p.pubupdate , p.pubdelete, p.pubtruncate FROM pg_publication AS p "
"JOIN pg_catalog.pg_roles AS r " "JOIN pg_catalog.pg_roles AS r "
"ON p.pubowner = r.oid " "ON p.pubowner = r.oid "
"WHERE p.pubname = '%s'" % self.name) "WHERE p.pubname = %(pname)s")
else: else:
query = ("SELECT r.rolname AS pubowner, p.puballtables, p.pubinsert, " query = ("SELECT r.rolname AS pubowner, p.puballtables, p.pubinsert, "
"p.pubupdate , p.pubdelete FROM pg_publication AS p " "p.pubupdate , p.pubdelete FROM pg_publication AS p "
"JOIN pg_catalog.pg_roles AS r " "JOIN pg_catalog.pg_roles AS r "
"ON p.pubowner = r.oid " "ON p.pubowner = r.oid "
"WHERE p.pubname = '%s'" % self.name) "WHERE p.pubname = %(pname)s")
result = exec_sql(self, query, add_to_executed=False) result = exec_sql(self, query, query_params={'pname': self.name}, add_to_executed=False)
if result: if result:
return result[0] return result[0]
else: else:
@ -452,8 +452,8 @@ class PgPublication():
List of dicts with published tables. List of dicts with published tables.
""" """
query = ("SELECT schemaname, tablename " query = ("SELECT schemaname, tablename "
"FROM pg_publication_tables WHERE pubname = '%s'" % self.name) "FROM pg_publication_tables WHERE pubname = %(pname)s")
return exec_sql(self, query, add_to_executed=False) return exec_sql(self, query, query_params={'pname': self.name}, add_to_executed=False)
def __pub_add_table(self, table, check_mode=False): def __pub_add_table(self, table, check_mode=False):
"""Add a table to the publication. """Add a table to the publication.

View file

@ -1,3 +1,6 @@
destructive destructive
shippable/posix/group4 shippable/posix/group4
skip/osx skip/osx
skip/freebsd
skip/opensuse
skip/centos