Skip to content

Commit

Permalink
fix(gitlab): avoid adding clause when table not present (#7868)
Browse files Browse the repository at this point in the history
  • Loading branch information
d4x1 authored Aug 9, 2024
1 parent eff8697 commit 4466340
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions backend/plugins/gitlab/tasks/trigger_job_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,18 @@ func GetAllPipelinesIterator(taskCtx plugin.SubTaskContext, apiCollector *helper
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("gp.gitlab_id not in (select json_extract(tj.input, '$.GitlabId') as gitlab_id from _raw_gitlab_api_trigger_job tj)"))
}
if apiCollector.IsIncremental() && apiCollector.GetSince() != nil {
clauses = append(clauses, dal.Where("gitlab_updated_at > ?", apiCollector.GetSince()))
}
// construct the input iterator

cursor, err := db.Cursor(clauses...)
if err != nil {
return nil, err
Expand Down

0 comments on commit 4466340

Please sign in to comment.