getandlist

This commit is contained in:
Michael McGuinness
2025-01-03 14:08:04 +00:00
parent 788b21594c
commit 483a47e4e0
8 changed files with 129 additions and 39 deletions
+12 -1
View File
@@ -5,7 +5,7 @@ SELECT id, config FROM queryConfigs where queryId = $1 and addedVersion >= $2 an
SELECT type FROM queries where id = $1;
-- name: DeprecateQuery :exec
INSERT INTO queryDeprecations (queryId) VALUES ($1) RETURNING id;
INSERT INTO queryDeprecations (queryId) VALUES ($1);
-- name: IsQueryDeprecated :one
SELECT EXISTS (
@@ -22,4 +22,15 @@ SELECT q.id, q.type, q.activeVersion, c.config, ARRAY_AGG(r.requiredQueryId) AS
and COALESCE(c.removedVersion, q.activeVersion - 1) < q.activeVersion
and r.addedVersion >= q.activeVersion
and COALESCE(r.removedVersion, q.activeVersion - 1) < q.activeVersion
GROUP BY q.id, c.config;
-- name: ListQueries :many
SELECT q.id, q.type, q.activeVersion, c.config, ARRAY_AGG(r.requiredQueryId) AS requiredIds
FROM queries AS q
JOIN queryConfigs AS c ON q.id = c.queryId
JOIN requiredQueries AS r ON q.id = r.queryId
WHERE c.addedVersion >= q.activeVersion
and COALESCE(c.removedVersion, q.activeVersion - 1) < q.activeVersion
and r.addedVersion >= q.activeVersion
and COALESCE(r.removedVersion, q.activeVersion - 1) < q.activeVersion
GROUP BY q.id, c.config;