Skip to content

Extensions in Precheck come false when they all match up #815

@vjeeva

Description

@vjeeva

This is happening due to the extensions being compared with different ordering.

❯ git diff
diff --git a/pgbelt/cmd/preflight.py b/pgbelt/cmd/preflight.py
index cd50a7f..aad720a 100644
--- a/pgbelt/cmd/preflight.py
+++ b/pgbelt/cmd/preflight.py
@@ -145,16 +145,14 @@ def _summary_table(
         ]
     ]

-    if compared_results is None:
-        results.sort(key=lambda d: d["db"])
-    else:
-        paired = sorted(zip(results, compared_results), key=lambda item: item[0]["db"])
-        if paired:
-            results, compared_results = map(list, zip(*paired))
-        else:
-            results, compared_results = [], []
+    results.sort(key=lambda d: d["db"])
+    compared_by_db = (
+        {entry["db"]: entry for entry in compared_results}
+        if compared_results is not None
+        else {}
+    )

-    for index, r in enumerate(results):
+    for r in results:
         root_ok = (
             r["users"]["root"]["rolcanlogin"]
             and r["users"]["root"]["rolcreaterole"]
@@ -233,7 +231,10 @@ def _summary_table(
         # If this is a destinatino DB, we are ensuring all source extensions are in the destination.
         # If not, we don't want this column in the table.
         if is_dest_db:
-            compare_entry = compared_results[index]
+            compare_entry = compared_by_db.get(r["db"])
+            if compare_entry is None:
+                summary_table[-1].append(style(False, "red"))
+                continue
             migrated_entries = _migrated_extension_entries(compare_entry, r)
             migrated_extensions = {entry["extension"] for entry in migrated_entries}

That'll fix it

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions