From 426e37ea92db037fe9367a6daa4d17622b1faf1d Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Wed, 20 Nov 2019 18:26:30 -0500 Subject: [PATCH] postgresql_privs - fix sort comparison (#65125) The result of .sort() is None, not the sorted object. The comparison was comparing the result of the .sort() method and not the sorted values. --- changelogs/fragments/postgresol_privs-fix-status-sorting.yaml | 2 ++ lib/ansible/modules/database/postgresql/postgresql_privs.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/postgresol_privs-fix-status-sorting.yaml diff --git a/changelogs/fragments/postgresol_privs-fix-status-sorting.yaml b/changelogs/fragments/postgresol_privs-fix-status-sorting.yaml new file mode 100644 index 00000000000..e62a249e6b5 --- /dev/null +++ b/changelogs/fragments/postgresol_privs-fix-status-sorting.yaml @@ -0,0 +1,2 @@ +bugfixes: + - postgresql_privs - sort results before comparing so that the values are compared and not the result of ``.sort()`` (https://github.com/ansible/ansible/pull/65125) diff --git a/lib/ansible/modules/database/postgresql/postgresql_privs.py b/lib/ansible/modules/database/postgresql/postgresql_privs.py index eafe4578d3e..b235d96c6a9 100644 --- a/lib/ansible/modules/database/postgresql/postgresql_privs.py +++ b/lib/ansible/modules/database/postgresql/postgresql_privs.py @@ -780,7 +780,9 @@ class Connection(object): executed_queries.append(query) self.cursor.execute(query) status_after = get_status(objs) - return status_before.sort() != status_after.sort() + status_before.sort() + status_after.sort() + return status_before != status_after class QueryBuilder(object):