UnifiedStorage: ensure list from history works across all 3 database backends (#91134)

* Ensure List is sorted by resource version DESC

* Ensure List is sorted by resource version DESC

* fix list in the past for postgres
This commit is contained in:
Georges Chaudy
2024-07-29 21:49:54 +02:00
committed by GitHub
parent 62f67e38b8
commit 7ad37ff4e4
3 changed files with 129 additions and 94 deletions
@@ -1,12 +1,13 @@
SELECT kv."resource_version", "value"
SELECT kv."resource_version", kv."value"
FROM "resource_history" as kv
JOIN (
SELECT "guid", max("resource_version") AS "resource_version"
INNER JOIN (
SELECT "namespace", "group", "resource", "name", max("resource_version") AS "resource_version"
FROM "resource_history" AS mkv
WHERE 1 = 1 AND "resource_version" <= ? AND "namespace" = ?
GROUP BY mkv."namespace", mkv."group", mkv."resource", mkv."name"
) AS maxkv ON maxkv."guid" = kv."guid"
WHERE kv."action" != 3
ORDER BY kv."resource_version" ASC
LIMIT ?, ?
) AS maxkv
ON maxkv."resource_version" = kv."resource_version" AND maxkv."namespace" = kv."namespace" AND maxkv."group" = kv."group" AND maxkv."resource" = kv."resource" AND maxkv."name" = kv."name"
WHERE kv."action" != 3 AND kv."namespace" = ?
ORDER BY kv."resource_version" DESC
LIMIT ? OFFSET ?
;