From f7256264510ba88d82934eb2676ff57b769c8a92 Mon Sep 17 00:00:00 2001 From: Joris Date: Mon, 30 Jan 2023 15:38:16 +0100 Subject: [PATCH] Add missing psycopg2.extras import (#399) Fixes https://github.com/ansible-collections/community.postgresql/issues/283 (cherry picked from commit bbaee4fe8214bd67f1d3af51aff3e5ac7e54f54b) --- changelogs/fragments/399-missing-import.yml | 2 ++ plugins/module_utils/postgres.py | 1 + 2 files changed, 3 insertions(+) create mode 100644 changelogs/fragments/399-missing-import.yml diff --git a/changelogs/fragments/399-missing-import.yml b/changelogs/fragments/399-missing-import.yml new file mode 100644 index 00000000..94eefdf0 --- /dev/null +++ b/changelogs/fragments/399-missing-import.yml @@ -0,0 +1,2 @@ +bugfixes: +- postgresql_query - could crash under certain conditions because of a missing import to `psycopg2.extras` (https://github.com/ansible-collections/community.postgresql/issues/283). diff --git a/plugins/module_utils/postgres.py b/plugins/module_utils/postgres.py index 3fb03faf..a5186065 100644 --- a/plugins/module_utils/postgres.py +++ b/plugins/module_utils/postgres.py @@ -15,6 +15,7 @@ psycopg2 = None # This line needs for unit tests try: import psycopg2 + import psycopg2.extras HAS_PSYCOPG2 = True except ImportError: HAS_PSYCOPG2 = False