From 3987e7bf3c9c967bcfc7af6cdfd8c29059ce0201 Mon Sep 17 00:00:00 2001 From: mdestefani Date: Thu, 8 Feb 2024 19:31:57 +0100 Subject: [PATCH 1/3] fix 6892 - avoid adding clause when table not present --- backend/plugins/gitlab/tasks/trigger_job_collector.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/plugins/gitlab/tasks/trigger_job_collector.go b/backend/plugins/gitlab/tasks/trigger_job_collector.go index 50e4d04e1ce..11fd246085f 100644 --- a/backend/plugins/gitlab/tasks/trigger_job_collector.go +++ b/backend/plugins/gitlab/tasks/trigger_job_collector.go @@ -83,10 +83,14 @@ func GetAllPipelinesIterator(taskCtx plugin.SubTaskContext, collectorWithState * dal.Select("gp.gitlab_id, gp.gitlab_id as iid"), dal.From("_tool_gitlab_pipelines gp"), dal.Where( - `gp.project_id = ? and gp.connection_id = ? and gp.gitlab_id not in (select json_extract(tj.input, '$.GitlabId') as gitlab_id from _raw_gitlab_api_trigger_job tj)`, + `gp.project_id = ? and gp.connection_id = ? `, data.Options.ProjectId, data.Options.ConnectionId, ), } + + if db.HasTable("_raw_gitlab_api_trigger_job") { + clauses = append(clauses, dal.Where("and gp.gitlab_id not in (select json_extract(tj.input, '$.GitlabId') as gitlab_id from _raw_gitlab_api_trigger_job tj)")) + } if collectorWithState.IsIncremental && collectorWithState.Since != nil { clauses = append(clauses, dal.Where("gitlab_updated_at > ?", collectorWithState.Since)) } From 464a41496c89d8d5e2559881c0e3bb85a8a05d9f Mon Sep 17 00:00:00 2001 From: Lynwee <1507509064@qq.com> Date: Fri, 26 Jul 2024 00:38:50 +0800 Subject: [PATCH 2/3] Update trigger_job_collector.go --- backend/plugins/gitlab/tasks/trigger_job_collector.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/plugins/gitlab/tasks/trigger_job_collector.go b/backend/plugins/gitlab/tasks/trigger_job_collector.go index b47461b13e5..6ddc18d7b7f 100644 --- a/backend/plugins/gitlab/tasks/trigger_job_collector.go +++ b/backend/plugins/gitlab/tasks/trigger_job_collector.go @@ -92,7 +92,7 @@ func GetAllPipelinesIterator(taskCtx plugin.SubTaskContext, apiCollector *helper if apiCollector.IsIncremental() && apiCollector.GetSince() != nil { clauses = append(clauses, dal.Where("gitlab_updated_at > ?", apiCollector.GetSince())) } - + cursor, err := db.Cursor(clauses...) if err != nil { return nil, err From 9dac178f20d165d4f5a84eca7c9bdb75641db202 Mon Sep 17 00:00:00 2001 From: Lynwee <1507509064@qq.com> Date: Fri, 26 Jul 2024 00:43:31 +0800 Subject: [PATCH 3/3] Update trigger_job_collector.go --- backend/plugins/gitlab/tasks/trigger_job_collector.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/plugins/gitlab/tasks/trigger_job_collector.go b/backend/plugins/gitlab/tasks/trigger_job_collector.go index 6ddc18d7b7f..e1b4652b9f5 100644 --- a/backend/plugins/gitlab/tasks/trigger_job_collector.go +++ b/backend/plugins/gitlab/tasks/trigger_job_collector.go @@ -92,7 +92,7 @@ func GetAllPipelinesIterator(taskCtx plugin.SubTaskContext, apiCollector *helper if apiCollector.IsIncremental() && apiCollector.GetSince() != nil { clauses = append(clauses, dal.Where("gitlab_updated_at > ?", apiCollector.GetSince())) } - + cursor, err := db.Cursor(clauses...) if err != nil { return nil, err