Fix ambiguous id when fetch Actions tasks (#30382) (#30383)

Backport #30382 by @wolfogre

Fix regression of #30331.

```txt
time="2024-04-10T02:23:49Z" level=error msg="failed to fetch task" func="[fetchTask]" file="[poller.go:91]" error="unknown: rpc error: code = Internal desc = pick task: CreateTaskForRunner: Error 1052 (23000): Column 'id' in field list is ambiguous"
```

I have tested it in my local env, and it should work now.

Co-authored-by: Jason Song <i@wolfogre.com>
(cherry picked from commit 189cfc1be1015367ca20c655ab6a5fd9847c527f)
This commit is contained in:
Giteabot 2024-04-10 11:24:31 +08:00 committed by Earl Warren
parent 952f4befa9
commit d4d3e89f18
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -228,7 +228,7 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
if runner.RepoID != 0 {
jobCond = builder.Eq{"repo_id": runner.RepoID}
} else if runner.OwnerID != 0 {
jobCond = builder.In("repo_id", builder.Select("id").From("repository").
jobCond = builder.In("repo_id", builder.Select("`repository`.id").From("repository").
Join("INNER", "repo_unit", "`repository`.id = `repo_unit`.repo_id").
Where(builder.Eq{"`repository`.owner_id": runner.OwnerID, "`repo_unit`.type": unit.TypeActions}))
}