diff options
author | Unknwon <u@gogs.io> | 2016-02-29 18:45:12 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-02-29 18:45:12 -0500 |
commit | ea80274229bca259a64fed7eca181e4a82ff0676 (patch) | |
tree | 92ab297632eddf55d33835413d681cede98da495 /models/issue.go | |
parent | 42a556a082d041cd546fdaa15a63ede5764134ba (diff) | |
download | gitea-ea80274229bca259a64fed7eca181e4a82ff0676.tar.gz gitea-ea80274229bca259a64fed7eca181e4a82ff0676.zip |
#2700 fix sqlite3 can't create issue with more than one label
Diffstat (limited to 'models/issue.go')
-rw-r--r-- | models/issue.go | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/models/issue.go b/models/issue.go index 94998d783d..4c33bc6b26 100644 --- a/models/issue.go +++ b/models/issue.go @@ -297,20 +297,17 @@ func newIssue(e *xorm.Session, repo *Repository, issue *Issue, labelIDs []int64, return err } - var label *Label - for _, id := range labelIDs { - if id == 0 { - continue - } + // During the session, SQLite3 dirver cannot handle retrieve objects after update something. + // So we have to get all needed labels first. + labels := make([]*Label, 0, len(labelIDs)) + if err = e.In("id", labelIDs).Find(&labels); err != nil { + return fmt.Errorf("Find all labels: %v", err) + } - label, err = getLabelByID(e, id) - if err != nil { - return err - } + for _, label := range labels { if err = issue.addLabel(e, label); err != nil { return fmt.Errorf("addLabel: %v", err) } - } if issue.MilestoneID > 0 { |