From 718f8aff942d9312c89a83853a27a18b91cbc859 Mon Sep 17 00:00:00 2001 From: spaced Date: Mon, 24 Jun 2024 02:04:54 +0200 Subject: [PATCH] fix(server): switch to `JSON_EXTRACT` and `JSON_UNQUOTE` for MySQL/MariaDB. Fixes #13202 (#13203) Signed-off-by: spaced (cherry picked from commit ac9cb3ae93bb441bb7ce09b74e99789adf599eae) --- persist/sqldb/workflow_archive.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persist/sqldb/workflow_archive.go b/persist/sqldb/workflow_archive.go index 9868d59944c8..10411968bb5f 100644 --- a/persist/sqldb/workflow_archive.go +++ b/persist/sqldb/workflow_archive.go @@ -380,7 +380,7 @@ func (r *workflowArchive) DeleteExpiredWorkflows(ttl time.Duration) error { func selectArchivedWorkflowQuery(t dbType) (*db.RawExpr, error) { switch t { case MySQL: - return db.Raw("name, namespace, uid, phase, startedat, finishedat, coalesce(workflow->>'$.metadata.labels', '{}') as labels,coalesce(workflow->>'$.metadata.annotations', '{}') as annotations, coalesce(workflow->>'$.status.progress', '') as progress, coalesce(workflow->>'$.metadata.creationTimestamp', '') as creationtimestamp, workflow->>'$.spec.suspend' as suspend, coalesce(workflow->>'$.status.message', '') as message, coalesce(workflow->>'$.status.estimatedDuration', '0') as estimatedduration, coalesce(workflow->>'$.status.resourcesDuration', '{}') as resourcesduration"), nil + return db.Raw("name, namespace, uid, phase, startedat, finishedat, coalesce(JSON_EXTRACT(workflow,'$.metadata.labels'), '{}') as labels,coalesce(JSON_EXTRACT(workflow,'$.metadata.annotations'), '{}') as annotations, coalesce(JSON_UNQUOTE(JSON_EXTRACT(workflow,'$.status.progress')), '') as progress, coalesce(JSON_UNQUOTE(JSON_EXTRACT(workflow,'$.metadata.creationTimestamp')), '') as creationtimestamp, JSON_UNQUOTE(JSON_EXTRACT(workflow,'$.spec.suspend')) as suspend, coalesce(JSON_UNQUOTE(JSON_EXTRACT(workflow,'$.status.message')), '') as message, coalesce(JSON_UNQUOTE(JSON_EXTRACT(workflow,'$.status.estimatedDuration')), '0') as estimatedduration, coalesce(JSON_EXTRACT(workflow,'$.status.resourcesDuration'), '{}') as resourcesduration"), nil case Postgres: return db.Raw("name, namespace, uid, phase, startedat, finishedat, coalesce((workflow::json)->'metadata'->>'labels', '{}') as labels, coalesce((workflow::json)->'metadata'->>'annotations', '{}') as annotations, coalesce((workflow::json)->'status'->>'progress', '') as progress, coalesce((workflow::json)->'metadata'->>'creationTimestamp', '') as creationtimestamp, (workflow::json)->'spec'->>'suspend' as suspend, coalesce((workflow::json)->'status'->>'message', '') as message, coalesce((workflow::json)->'status'->>'estimatedDuration', '0') as estimatedduration, coalesce((workflow::json)->'status'->>'resourcesDuration', '{}') as resourcesduration"), nil }