From 75d41ca3711018b3ded1a4f529b15d4f31f39d55 Mon Sep 17 00:00:00 2001 From: Jake Moshenko Date: Mon, 23 Feb 2015 12:36:14 -0500 Subject: [PATCH] Switch to an inner inner subquery to make mysql arbitrarily happy. --- data/model/legacy.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/data/model/legacy.py b/data/model/legacy.py index 331bf2720..5e5705a19 100644 --- a/data/model/legacy.py +++ b/data/model/legacy.py @@ -1579,13 +1579,19 @@ def list_repository_tags(namespace_name, repository_name, include_hidden=False): def _garbage_collect_tags(namespace_name, repository_name): + inner = (RepositoryTag + .select(RepositoryTag.id, + RepositoryTag.lifetime_end_ts, + RepositoryTag.repository) + .alias('rt')) to_delete = (RepositoryTag - .select(RepositoryTag.id) - .join(Repository) + .select(inner.c.id) + .from_(inner) + .join(Repository, on=(inner.c.repository_id == Repository.id)) .join(Namespace, on=(Repository.namespace_user == Namespace.id)) .where(Repository.name == repository_name, Namespace.username == namespace_name, - ~(RepositoryTag.lifetime_end_ts >> None), - (RepositoryTag.lifetime_end_ts + Namespace.removed_tag_expiration_s) <= + ~(inner.c.lifetime_end_ts >> None), + (inner.c.lifetime_end_ts + Namespace.removed_tag_expiration_s) <= int(time.time()))) (RepositoryTag