@@ -282,7 +282,6 @@ type NewIssueOptions struct {
282282
283283// NewIssueWithIndex creates issue with given index
284284func NewIssueWithIndex (ctx context.Context , doer * user_model.User , opts NewIssueOptions ) (err error ) {
285- e := db .GetEngine (ctx )
286285 opts .Issue .Title = strings .TrimSpace (opts .Issue .Title )
287286
288287 if opts .Issue .MilestoneID > 0 {
@@ -306,7 +305,7 @@ func NewIssueWithIndex(ctx context.Context, doer *user_model.User, opts NewIssue
306305 return fmt .Errorf ("issue exist" )
307306 }
308307
309- if _ , err := e .Insert (opts .Issue ); err != nil {
308+ if err := db .Insert (ctx , opts .Issue ); err != nil {
310309 return err
311310 }
312311
@@ -336,7 +335,7 @@ func NewIssueWithIndex(ctx context.Context, doer *user_model.User, opts NewIssue
336335 // During the session, SQLite3 driver cannot handle retrieve objects after update something.
337336 // So we have to get all needed labels first.
338337 labels := make ([]* Label , 0 , len (opts .LabelIDs ))
339- if err = e .In ("id" , opts .LabelIDs ).Find (& labels ); err != nil {
338+ if err = db . GetEngine ( ctx ) .In ("id" , opts .LabelIDs ).Find (& labels ); err != nil {
340339 return fmt .Errorf ("find all labels [label_ids: %v]: %w" , opts .LabelIDs , err )
341340 }
342341
@@ -368,8 +367,8 @@ func NewIssueWithIndex(ctx context.Context, doer *user_model.User, opts NewIssue
368367
369368 for i := 0 ; i < len (attachments ); i ++ {
370369 attachments [i ].IssueID = opts .Issue .ID
371- if _ , err = e . ID (attachments [i ].ID ).Update (attachments [i ]); err != nil {
372- return fmt .Errorf ("update attachment [id: %d]: %w" , attachments [i ].ID , err )
370+ if _ , err = db . GetEngine ( ctx ). ID (attachments [i ].ID ). Cols ( "issue_id" ).Update (attachments [i ]); err != nil {
371+ return fmt .Errorf ("update attachment issue_id [id: %d]: %w" , attachments [i ].ID , err )
373372 }
374373 }
375374 }
0 commit comments