Skip to content

Commit 4466340

Browse files
authored
fix(gitlab): avoid adding clause when table not present (#7868)
1 parent eff8697 commit 4466340

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

backend/plugins/gitlab/tasks/trigger_job_collector.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,18 @@ func GetAllPipelinesIterator(taskCtx plugin.SubTaskContext, apiCollector *helper
8181
dal.Select("gp.gitlab_id, gp.gitlab_id as iid"),
8282
dal.From("_tool_gitlab_pipelines gp"),
8383
dal.Where(
84-
`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)`,
84+
`gp.project_id = ? and gp.connection_id = ? `,
8585
data.Options.ProjectId, data.Options.ConnectionId,
8686
),
8787
}
88+
89+
if db.HasTable("_raw_gitlab_api_trigger_job") {
90+
clauses = append(clauses, dal.Where("gp.gitlab_id not in (select json_extract(tj.input, '$.GitlabId') as gitlab_id from _raw_gitlab_api_trigger_job tj)"))
91+
}
8892
if apiCollector.IsIncremental() && apiCollector.GetSince() != nil {
8993
clauses = append(clauses, dal.Where("gitlab_updated_at > ?", apiCollector.GetSince()))
9094
}
91-
// construct the input iterator
95+
9296
cursor, err := db.Cursor(clauses...)
9397
if err != nil {
9498
return nil, err

0 commit comments

Comments
 (0)