Skip to content

Commit db45504

Browse files
authored
Refactor get_active_release_names sql query (#2657)
This makes the query work even if rules_scheduled_changes is empty, by not joining on that table.
1 parent 88de160 commit db45504

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

scripts/manage-db.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ def get_active_release_names(trans, source_table="releases_json"):
105105
# - All releases referenced by a Rule or a Active Scheduled Rule Change
106106
# - All releases referenced by a Release from the above query
107107
query_release_mapping = f"""SELECT DISTINCT releases.* \
108-
FROM {source_table} as releases, rules, rules_scheduled_changes \
109-
WHERE (releases.name IN (rules.mapping, rules.fallbackMapping))
110-
OR (rules_scheduled_changes.complete = 0 AND
108+
FROM {source_table} as releases \
109+
WHERE EXISTS(SELECT 1 FROM rules WHERE releases.name IN (rules.mapping, rules.fallbackMapping))
110+
OR EXISTS(SELECT 1 FROM rules_scheduled_changes WHERE rules_scheduled_changes.complete = 0 AND
111111
releases.name IN (rules_scheduled_changes.base_mapping, rules_scheduled_changes.base_fallbackMapping))
112112
"""
113113
result = trans.execute(query_release_mapping).fetchall()

0 commit comments

Comments
 (0)