diff --git a/changelogs/fragments/858-negated-change-report.yml b/changelogs/fragments/858-negated-change-report.yml new file mode 100644 index 00000000..9db88fde --- /dev/null +++ b/changelogs/fragments/858-negated-change-report.yml @@ -0,0 +1,2 @@ +bugfixes: + - postgresql_schema - change reported in check_mode was negated. Now it reports a change when removing an existing schema (https://github.com/ansible-collections/community.postgresql/pull/858) \ No newline at end of file diff --git a/plugins/modules/postgresql_schema.py b/plugins/modules/postgresql_schema.py index 70dbe903..aee79bcf 100644 --- a/plugins/modules/postgresql_schema.py +++ b/plugins/modules/postgresql_schema.py @@ -288,7 +288,7 @@ def main(): try: if module.check_mode: if state == "absent": - changed = not schema_exists(cursor, schema) + changed = schema_exists(cursor, schema) elif state == "present": changed = not schema_matches(cursor, schema, owner, comment) module.exit_json(changed=changed, schema=schema) diff --git a/tests/integration/targets/postgresql_schema/tasks/postgresql_schema_initial.yml b/tests/integration/targets/postgresql_schema/tasks/postgresql_schema_initial.yml index 625fb45e..e7057ad6 100644 --- a/tests/integration/targets/postgresql_schema/tasks/postgresql_schema_initial.yml +++ b/tests/integration/targets/postgresql_schema/tasks/postgresql_schema_initial.yml @@ -99,7 +99,7 @@ # Checks - assert: that: - - result is not changed + - result is changed - name: Check that the new schema "acme" still exists become: true