This commit is contained in:
Georges Chaudy 2024-07-10 10:45:56 +02:00
parent ccf12406a6
commit dd383150bf
No known key found for this signature in database
GPG Key ID: 0EE887FFCA1DB6EF
15 changed files with 24 additions and 15 deletions

View File

@ -136,8 +136,9 @@ func (b *backend) WriteEvent(ctx context.Context, event resource.WriteEvent) (in
return b.update(ctx, event)
case resource.WatchEvent_DELETED:
return b.delete(ctx, event)
}
default:
return 0, fmt.Errorf("unsupported event type")
}
}
func (b *backend) create(ctx context.Context, event resource.WriteEvent) (int64, error) {

View File

@ -8,4 +8,5 @@ JOIN (
) AS maxkv ON maxkv."guid" = kv."guid"
WHERE kv."action" != 3
ORDER BY kv."resource_version" ASC
LIMIT ?, ?;
LIMIT ?, ?
;

View File

@ -1 +0,0 @@
SELECT max("resource_version") FROM "resource_history";

View File

@ -1,2 +1,3 @@
UPDATE "resource_history" SET "resource_version" = ?
WHERE "guid" = ?;
WHERE "guid" = ?
;

View File

@ -1,3 +1,4 @@
INSERT INTO "resource"
("guid", "group", "resource", "namespace", "name", "value", "action")
VALUES (?, ?, ?, ?, ?, ?, ?);
VALUES (?, ?, ?, ?, ?, ?, ?)
;

View File

@ -1,3 +1,4 @@
SELECT "resource_version", "value"
FROM "resource"
WHERE 1 = 1 AND "namespace" = ? AND "group" = ? AND "resource" = ? AND "name" = ?;
WHERE 1 = 1 AND "namespace" = ? AND "group" = ? AND "resource" = ? AND "name" = ?
;

View File

@ -1,2 +1,4 @@
UPDATE "resource" SET "guid" = ?, "value" = ?, "action" = ?
WHERE 1 =1 AND "group" = ? AND "resource" = ? AND "namespace" = ? AND "name" = ? ;
WHERE 1 =1 AND "group" = ? AND "resource" = ? AND "namespace" = ? AND "name" = ?
;

View File

@ -1,2 +1,4 @@
UPDATE "resource" SET "resource_version" = ?
WHERE "guid" = ?;
WHERE "guid" = ?
;

View File

@ -1,3 +1,4 @@
SELECT "resource_version"
FROM "resource_version"
WHERE 1 = 1 AND "group" = ? AND "resource" = ?;
WHERE 1 = 1 AND "group" = ? AND "resource" = ?
;