Extensions in Precheck come false when they all match up
- Dominant language
- Python
- Stars
- 22
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
Research direction
Start by reading _summary_table in pg belt/cmd/preflight.py and follow the Precheck path that builds the extension comparison. Run the precheck with matching extensions in different orders; done when those extensions are no longer reported as false.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python
- Domain
- cli, databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100