Browse Source

Replace deprecated Id method with ID (#2655)

Ethan Koenig 1 year ago
parent
commit
aa962deec0

+ 2 - 2
models/action_test.go

@@ -76,7 +76,7 @@ func TestRenameRepoAction(t *testing.T) {
76 76
 	assert.NoError(t, RenameRepoAction(user, oldRepoName, repo))
77 77
 	AssertExistsAndLoadBean(t, actionBean)
78 78
 
79
-	_, err := x.Id(repo.ID).Cols("name", "lower_name").Update(repo)
79
+	_, err := x.ID(repo.ID).Cols("name", "lower_name").Update(repo)
80 80
 	assert.NoError(t, err)
81 81
 	CheckConsistencyFor(t, &Action{})
82 82
 }
@@ -337,7 +337,7 @@ func TestTransferRepoAction(t *testing.T) {
337 337
 	assert.NoError(t, TransferRepoAction(user2, user2, repo))
338 338
 	AssertExistsAndLoadBean(t, actionBean)
339 339
 
340
-	_, err := x.Id(repo.ID).Cols("owner_id").Update(repo)
340
+	_, err := x.ID(repo.ID).Cols("owner_id").Update(repo)
341 341
 	assert.NoError(t, err)
342 342
 	CheckConsistencyFor(t, &Action{})
343 343
 }

+ 1 - 1
models/admin.go

@@ -93,7 +93,7 @@ func Notices(page, pageSize int) ([]*Notice, error) {
93 93
 
94 94
 // DeleteNotice deletes a system notice by given ID.
95 95
 func DeleteNotice(id int64) error {
96
-	_, err := x.Id(id).Delete(new(Notice))
96
+	_, err := x.ID(id).Delete(new(Notice))
97 97
 	return err
98 98
 }
99 99
 

+ 1 - 1
models/branches.go

@@ -142,7 +142,7 @@ func UpdateProtectBranch(repo *Repository, protectBranch *ProtectedBranch, white
142 142
 		return nil
143 143
 	}
144 144
 
145
-	if _, err = x.Id(protectBranch.ID).AllCols().Update(protectBranch); err != nil {
145
+	if _, err = x.ID(protectBranch.ID).AllCols().Update(protectBranch); err != nil {
146 146
 		return fmt.Errorf("Update: %v", err)
147 147
 	}
148 148
 

+ 1 - 1
models/gpg_key.go

@@ -73,7 +73,7 @@ func ListGPGKeys(uid int64) ([]*GPGKey, error) {
73 73
 // GetGPGKeyByID returns public key by given ID.
74 74
 func GetGPGKeyByID(keyID int64) (*GPGKey, error) {
75 75
 	key := new(GPGKey)
76
-	has, err := x.Id(keyID).Get(key)
76
+	has, err := x.ID(keyID).Get(key)
77 77
 	if err != nil {
78 78
 		return nil, err
79 79
 	} else if !has {

+ 4 - 4
models/issue.go

@@ -570,7 +570,7 @@ func (issue *Issue) ReadBy(userID int64) error {
570 570
 }
571 571
 
572 572
 func updateIssueCols(e Engine, issue *Issue, cols ...string) error {
573
-	if _, err := e.Id(issue.ID).Cols(cols...).Update(issue); err != nil {
573
+	if _, err := e.ID(issue.ID).Cols(cols...).Update(issue); err != nil {
574 574
 		return err
575 575
 	}
576 576
 	UpdateIssueIndexer(issue.ID)
@@ -911,7 +911,7 @@ func newIssue(e *xorm.Session, doer *User, opts NewIssueOptions) (err error) {
911 911
 
912 912
 		for i := 0; i < len(attachments); i++ {
913 913
 			attachments[i].IssueID = opts.Issue.ID
914
-			if _, err = e.Id(attachments[i].ID).Update(attachments[i]); err != nil {
914
+			if _, err = e.ID(attachments[i].ID).Update(attachments[i]); err != nil {
915 915
 				return fmt.Errorf("update attachment [id: %d]: %v", attachments[i].ID, err)
916 916
 			}
917 917
 		}
@@ -1008,7 +1008,7 @@ func GetIssueByIndex(repoID, index int64) (*Issue, error) {
1008 1008
 
1009 1009
 func getIssueByID(e Engine, id int64) (*Issue, error) {
1010 1010
 	issue := new(Issue)
1011
-	has, err := e.Id(id).Get(issue)
1011
+	has, err := e.ID(id).Get(issue)
1012 1012
 	if err != nil {
1013 1013
 		return nil, err
1014 1014
 	} else if !has {
@@ -1435,7 +1435,7 @@ func GetRepoIssueStats(repoID, uid int64, filterMode int, isPull bool) (numOpen
1435 1435
 }
1436 1436
 
1437 1437
 func updateIssue(e Engine, issue *Issue) error {
1438
-	_, err := e.Id(issue.ID).AllCols().Update(issue)
1438
+	_, err := e.ID(issue.ID).AllCols().Update(issue)
1439 1439
 	if err != nil {
1440 1440
 		return err
1441 1441
 	}

+ 3 - 3
models/issue_comment.go

@@ -356,7 +356,7 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
356 356
 			attachments[i].IssueID = opts.Issue.ID
357 357
 			attachments[i].CommentID = comment.ID
358 358
 			// No assign value could be 0, so ignore AllCols().
359
-			if _, err = e.Id(attachments[i].ID).Update(attachments[i]); err != nil {
359
+			if _, err = e.ID(attachments[i].ID).Update(attachments[i]); err != nil {
360 360
 				return nil, fmt.Errorf("update attachment [%d]: %v", attachments[i].ID, err)
361 361
 			}
362 362
 		}
@@ -569,7 +569,7 @@ func CreateRefComment(doer *User, repo *Repository, issue *Issue, content, commi
569 569
 // GetCommentByID returns the comment by given ID.
570 570
 func GetCommentByID(id int64) (*Comment, error) {
571 571
 	c := new(Comment)
572
-	has, err := x.Id(id).Get(c)
572
+	has, err := x.ID(id).Get(c)
573 573
 	if err != nil {
574 574
 		return nil, err
575 575
 	} else if !has {
@@ -647,7 +647,7 @@ func GetCommentsByRepoIDSince(repoID, since int64) ([]*Comment, error) {
647 647
 
648 648
 // UpdateComment updates information of comment.
649 649
 func UpdateComment(c *Comment) error {
650
-	if _, err := x.Id(c.ID).AllCols().Update(c); err != nil {
650
+	if _, err := x.ID(c.ID).AllCols().Update(c); err != nil {
651 651
 		return err
652 652
 	} else if c.Type == CommentTypeComment {
653 653
 		UpdateIssueIndexer(c.IssueID)

+ 2 - 2
models/issue_label.go

@@ -222,7 +222,7 @@ func GetLabelsByIssueID(issueID int64) ([]*Label, error) {
222 222
 }
223 223
 
224 224
 func updateLabel(e Engine, l *Label) error {
225
-	_, err := e.Id(l.ID).AllCols().Update(l)
225
+	_, err := e.ID(l.ID).AllCols().Update(l)
226 226
 	return err
227 227
 }
228 228
 
@@ -247,7 +247,7 @@ func DeleteLabel(repoID, labelID int64) error {
247 247
 		return err
248 248
 	}
249 249
 
250
-	if _, err = sess.Id(labelID).Delete(new(Label)); err != nil {
250
+	if _, err = sess.ID(labelID).Delete(new(Label)); err != nil {
251 251
 		return err
252 252
 	} else if _, err = sess.
253 253
 		Where("label_id = ?", labelID).

+ 4 - 4
models/issue_milestone.go

@@ -165,7 +165,7 @@ func GetMilestones(repoID int64, page int, isClosed bool, sortType string) ([]*M
165 165
 }
166 166
 
167 167
 func updateMilestone(e Engine, m *Milestone) error {
168
-	_, err := e.Id(m.ID).AllCols().Update(m)
168
+	_, err := e.ID(m.ID).AllCols().Update(m)
169 169
 	return err
170 170
 }
171 171
 
@@ -221,7 +221,7 @@ func ChangeMilestoneStatus(m *Milestone, isClosed bool) (err error) {
221 221
 
222 222
 	repo.NumMilestones = int(countRepoMilestones(sess, repo.ID))
223 223
 	repo.NumClosedMilestones = int(countRepoClosedMilestones(sess, repo.ID))
224
-	if _, err = sess.Id(repo.ID).Cols("num_milestones, num_closed_milestones").Update(repo); err != nil {
224
+	if _, err = sess.ID(repo.ID).Cols("num_milestones, num_closed_milestones").Update(repo); err != nil {
225 225
 		return err
226 226
 	}
227 227
 	return sess.Commit()
@@ -329,13 +329,13 @@ func DeleteMilestoneByRepoID(repoID, id int64) error {
329 329
 		return err
330 330
 	}
331 331
 
332
-	if _, err = sess.Id(m.ID).Delete(new(Milestone)); err != nil {
332
+	if _, err = sess.ID(m.ID).Delete(new(Milestone)); err != nil {
333 333
 		return err
334 334
 	}
335 335
 
336 336
 	repo.NumMilestones = int(countRepoMilestones(sess, repo.ID))
337 337
 	repo.NumClosedMilestones = int(countRepoClosedMilestones(sess, repo.ID))
338
-	if _, err = sess.Id(repo.ID).Cols("num_milestones, num_closed_milestones").Update(repo); err != nil {
338
+	if _, err = sess.ID(repo.ID).Cols("num_milestones, num_closed_milestones").Update(repo); err != nil {
339 339
 		return err
340 340
 	}
341 341
 

+ 1 - 1
models/issue_user.go

@@ -101,7 +101,7 @@ func UpdateIssueUsersByMentions(e Engine, issueID int64, uids []int64) error {
101 101
 
102 102
 		iu.IsMentioned = true
103 103
 		if has {
104
-			_, err = e.Id(iu.ID).Cols("is_mentioned").Update(iu)
104
+			_, err = e.ID(iu.ID).Cols("is_mentioned").Update(iu)
105 105
 		} else {
106 106
 			_, err = e.Insert(iu)
107 107
 		}

+ 1 - 1
models/issue_watch.go

@@ -62,7 +62,7 @@ func CreateOrUpdateIssueWatch(userID, issueID int64, isWatching bool) error {
62 62
 	} else {
63 63
 		iw.IsWatching = isWatching
64 64
 
65
-		if _, err := x.Id(iw.ID).Cols("is_watching", "updated_unix").Update(iw); err != nil {
65
+		if _, err := x.ID(iw.ID).Cols("is_watching", "updated_unix").Update(iw); err != nil {
66 66
 			return err
67 67
 		}
68 68
 	}

+ 5 - 5
models/login_source.go

@@ -308,7 +308,7 @@ func LoginSources() ([]*LoginSource, error) {
308 308
 // GetLoginSourceByID returns login source by given ID.
309 309
 func GetLoginSourceByID(id int64) (*LoginSource, error) {
310 310
 	source := new(LoginSource)
311
-	has, err := x.Id(id).Get(source)
311
+	has, err := x.ID(id).Get(source)
312 312
 	if err != nil {
313 313
 		return nil, err
314 314
 	} else if !has {
@@ -328,7 +328,7 @@ func UpdateSource(source *LoginSource) error {
328 328
 		}
329 329
 	}
330 330
 
331
-	_, err := x.Id(source.ID).AllCols().Update(source)
331
+	_, err := x.ID(source.ID).AllCols().Update(source)
332 332
 	if err == nil && source.IsOAuth2() && source.IsActived {
333 333
 		oAuth2Config := source.OAuth2()
334 334
 		err = oauth2.RegisterProvider(source.Name, oAuth2Config.Provider, oAuth2Config.ClientID, oAuth2Config.ClientSecret, oAuth2Config.OpenIDConnectAutoDiscoveryURL, oAuth2Config.CustomURLMapping)
@@ -336,7 +336,7 @@ func UpdateSource(source *LoginSource) error {
336 336
 
337 337
 		if err != nil {
338 338
 			// restore original values since we cannot update the provider it self
339
-			x.Id(source.ID).AllCols().Update(originalLoginSource)
339
+			x.ID(source.ID).AllCols().Update(originalLoginSource)
340 340
 		}
341 341
 	}
342 342
 	return err
@@ -362,7 +362,7 @@ func DeleteSource(source *LoginSource) error {
362 362
 		oauth2.RemoveProvider(source.Name)
363 363
 	}
364 364
 
365
-	_, err = x.Id(source.ID).Delete(new(LoginSource))
365
+	_, err = x.ID(source.ID).Delete(new(LoginSource))
366 366
 	return err
367 367
 }
368 368
 
@@ -647,7 +647,7 @@ func UserSignIn(username, password string) (*User, error) {
647 647
 
648 648
 		default:
649 649
 			var source LoginSource
650
-			hasSource, err := x.Id(user.LoginSource).Get(&source)
650
+			hasSource, err := x.ID(user.LoginSource).Get(&source)
651 651
 			if err != nil {
652 652
 				return nil, err
653 653
 			} else if !hasSource {

+ 2 - 2
models/migrations/migrations.go

@@ -173,7 +173,7 @@ Please try to upgrade to a lower version (>= v0.6.0) first, then upgrade to curr
173 173
 	if int(v-minDBVersion) > len(migrations) {
174 174
 		// User downgraded Gitea.
175 175
 		currentVersion.Version = int64(len(migrations) + minDBVersion)
176
-		_, err = x.Id(1).Update(currentVersion)
176
+		_, err = x.ID(1).Update(currentVersion)
177 177
 		return err
178 178
 	}
179 179
 	for i, m := range migrations[v-minDBVersion:] {
@@ -182,7 +182,7 @@ Please try to upgrade to a lower version (>= v0.6.0) first, then upgrade to curr
182 182
 			return fmt.Errorf("do migrate: %v", err)
183 183
 		}
184 184
 		currentVersion.Version = v + int64(i) + 1
185
-		if _, err = x.Id(1).Update(currentVersion); err != nil {
185
+		if _, err = x.ID(1).Update(currentVersion); err != nil {
186 186
 			return err
187 187
 		}
188 188
 	}

+ 1 - 1
models/migrations/v28.go

@@ -67,7 +67,7 @@ func addRepoSize(x *xorm.Engine) (err error) {
67 67
 			}
68 68
 
69 69
 			repo.Size = countObject.Size + countObject.SizePack
70
-			if _, err = x.Id(repo.ID).Cols("size").Update(repo); err != nil {
70
+			if _, err = x.ID(repo.ID).Cols("size").Update(repo); err != nil {
71 71
 				return fmt.Errorf("update size: %v", err)
72 72
 			}
73 73
 		}

+ 1 - 1
models/migrations/v38.go

@@ -33,7 +33,7 @@ func removeCommitsUnitType(x *xorm.Engine) (err error) {
33 33
 				}
34 34
 			}
35 35
 			team.UnitTypes = ut
36
-			if _, err := x.Id(team.ID).Cols("unit_types").Update(team); err != nil {
36
+			if _, err := x.ID(team.ID).Cols("unit_types").Update(team); err != nil {
37 37
 				return err
38 38
 			}
39 39
 		}

+ 1 - 1
models/migrations/v39.go

@@ -56,7 +56,7 @@ func addTimetracking(x *xorm.Engine) error {
56 56
 			changes = true
57 57
 		}
58 58
 		if changes {
59
-			if _, err := x.Id(unit.ID).Cols("config").Update(unit); err != nil {
59
+			if _, err := x.ID(unit.ID).Cols("config").Update(unit); err != nil {
60 60
 				return err
61 61
 			}
62 62
 		}

+ 1 - 1
models/models.go

@@ -37,7 +37,7 @@ type Engine interface {
37 37
 	Exec(string, ...interface{}) (sql.Result, error)
38 38
 	Find(interface{}, ...interface{}) error
39 39
 	Get(interface{}) (bool, error)
40
-	Id(interface{}) *xorm.Session
40
+	ID(interface{}) *xorm.Session
41 41
 	In(string, ...interface{}) *xorm.Session
42 42
 	Incr(column string, arg ...interface{}) *xorm.Session
43 43
 	Insert(...interface{}) (int64, error)

+ 3 - 3
models/notification.go

@@ -195,7 +195,7 @@ func updateIssueNotification(e Engine, userID, issueID, updatedByID int64) error
195 195
 	notification.Status = NotificationStatusUnread
196 196
 	notification.UpdatedBy = updatedByID
197 197
 
198
-	_, err = e.Id(notification.ID).Update(notification)
198
+	_, err = e.ID(notification.ID).Update(notification)
199 199
 	return err
200 200
 }
201 201
 
@@ -274,7 +274,7 @@ func setNotificationStatusReadIfUnread(e Engine, userID, issueID int64) error {
274 274
 
275 275
 	notification.Status = NotificationStatusRead
276 276
 
277
-	_, err = e.Id(notification.ID).Update(notification)
277
+	_, err = e.ID(notification.ID).Update(notification)
278 278
 	return err
279 279
 }
280 280
 
@@ -291,7 +291,7 @@ func SetNotificationStatus(notificationID int64, user *User, status Notification
291 291
 
292 292
 	notification.Status = status
293 293
 
294
-	_, err = x.Id(notificationID).Update(notification)
294
+	_, err = x.ID(notificationID).Update(notification)
295 295
 	return err
296 296
 }
297 297
 

+ 3 - 3
models/org.go

@@ -259,7 +259,7 @@ func deleteOrg(e *xorm.Session, u *User) error {
259 259
 		return fmt.Errorf("deleteBeans: %v", err)
260 260
 	}
261 261
 
262
-	if _, err = e.Id(u.ID).Delete(new(User)); err != nil {
262
+	if _, err = e.ID(u.ID).Delete(new(User)); err != nil {
263 263
 		return fmt.Errorf("Delete: %v", err)
264 264
 	}
265 265
 
@@ -412,7 +412,7 @@ func ChangeOrgUserStatus(orgID, uid int64, public bool) error {
412 412
 	}
413 413
 
414 414
 	ou.IsPublic = public
415
-	_, err = x.Id(ou.ID).Cols("is_public").Update(ou)
415
+	_, err = x.ID(ou.ID).Cols("is_public").Update(ou)
416 416
 	return err
417 417
 }
418 418
 
@@ -480,7 +480,7 @@ func RemoveOrgUser(orgID, userID int64) error {
480 480
 		return err
481 481
 	}
482 482
 
483
-	if _, err := sess.Id(ou.ID).Delete(ou); err != nil {
483
+	if _, err := sess.ID(ou.ID).Delete(ou); err != nil {
484 484
 		return err
485 485
 	} else if _, err = sess.Exec("UPDATE `user` SET num_members=num_members-1 WHERE id=?", orgID); err != nil {
486 486
 		return err

+ 10 - 10
models/org_team.go

@@ -96,7 +96,7 @@ func (t *Team) addRepository(e Engine, repo *Repository) (err error) {
96 96
 	}
97 97
 
98 98
 	t.NumRepos++
99
-	if _, err = e.Id(t.ID).Cols("num_repos").Update(t); err != nil {
99
+	if _, err = e.ID(t.ID).Cols("num_repos").Update(t); err != nil {
100 100
 		return fmt.Errorf("update team: %v", err)
101 101
 	}
102 102
 
@@ -142,7 +142,7 @@ func (t *Team) removeRepository(e Engine, repo *Repository, recalculate bool) (e
142 142
 	}
143 143
 
144 144
 	t.NumRepos--
145
-	if _, err = e.Id(t.ID).Cols("num_repos").Update(t); err != nil {
145
+	if _, err = e.ID(t.ID).Cols("num_repos").Update(t); err != nil {
146 146
 		return err
147 147
 	}
148 148
 
@@ -231,7 +231,7 @@ func NewTeam(t *Team) (err error) {
231 231
 		return err
232 232
 	}
233 233
 
234
-	has, err := x.Id(t.OrgID).Get(new(User))
234
+	has, err := x.ID(t.OrgID).Get(new(User))
235 235
 	if err != nil {
236 236
 		return err
237 237
 	} else if !has {
@@ -289,7 +289,7 @@ func GetTeam(orgID int64, name string) (*Team, error) {
289 289
 
290 290
 func getTeamByID(e Engine, teamID int64) (*Team, error) {
291 291
 	t := new(Team)
292
-	has, err := e.Id(teamID).Get(t)
292
+	has, err := e.ID(teamID).Get(t)
293 293
 	if err != nil {
294 294
 		return nil, err
295 295
 	} else if !has {
@@ -331,7 +331,7 @@ func UpdateTeam(t *Team, authChanged bool) (err error) {
331 331
 		return ErrTeamAlreadyExist{t.OrgID, t.LowerName}
332 332
 	}
333 333
 
334
-	if _, err = sess.Id(t.ID).AllCols().Update(t); err != nil {
334
+	if _, err = sess.ID(t.ID).AllCols().Update(t); err != nil {
335 335
 		return fmt.Errorf("update: %v", err)
336 336
 	}
337 337
 
@@ -387,7 +387,7 @@ func DeleteTeam(t *Team) error {
387 387
 	}
388 388
 
389 389
 	// Delete team.
390
-	if _, err := sess.Id(t.ID).Delete(new(Team)); err != nil {
390
+	if _, err := sess.ID(t.ID).Delete(new(Team)); err != nil {
391 391
 		return err
392 392
 	}
393 393
 	// Update organization number of teams.
@@ -498,7 +498,7 @@ func AddTeamMember(team *Team, userID int64) error {
498 498
 		TeamID: team.ID,
499 499
 	}); err != nil {
500 500
 		return err
501
-	} else if _, err := sess.Id(team.ID).Update(team); err != nil {
501
+	} else if _, err := sess.ID(team.ID).Update(team); err != nil {
502 502
 		return err
503 503
 	}
504 504
 
@@ -521,7 +521,7 @@ func AddTeamMember(team *Team, userID int64) error {
521 521
 	if team.IsOwnerTeam() {
522 522
 		ou.IsOwner = true
523 523
 	}
524
-	if _, err := sess.Id(ou.ID).Cols("num_teams, is_owner").Update(ou); err != nil {
524
+	if _, err := sess.ID(ou.ID).Cols("num_teams, is_owner").Update(ou); err != nil {
525 525
 		return err
526 526
 	}
527 527
 
@@ -551,7 +551,7 @@ func removeTeamMember(e Engine, team *Team, userID int64) error {
551 551
 	}); err != nil {
552 552
 		return err
553 553
 	} else if _, err = e.
554
-		Id(team.ID).
554
+		ID(team.ID).
555 555
 		Cols("num_members").
556 556
 		Update(team); err != nil {
557 557
 		return err
@@ -578,7 +578,7 @@ func removeTeamMember(e Engine, team *Team, userID int64) error {
578 578
 		ou.IsOwner = false
579 579
 	}
580 580
 	if _, err = e.
581
-		Id(ou.ID).
581
+		ID(ou.ID).
582 582
 		Cols("num_teams").
583 583
 		Update(ou); err != nil {
584 584
 		return err

+ 4 - 4
models/pull.go

@@ -422,7 +422,7 @@ func (pr *PullRequest) setMerged() (err error) {
422 422
 	if err = pr.Issue.changeStatus(sess, pr.Merger, pr.Issue.Repo, true); err != nil {
423 423
 		return fmt.Errorf("Issue.changeStatus: %v", err)
424 424
 	}
425
-	if _, err = sess.Id(pr.ID).Cols("has_merged").Update(pr); err != nil {
425
+	if _, err = sess.ID(pr.ID).Cols("has_merged").Update(pr); err != nil {
426 426
 		return fmt.Errorf("update pull request: %v", err)
427 427
 	}
428 428
 
@@ -795,7 +795,7 @@ func GetPullRequestByIndex(repoID int64, index int64) (*PullRequest, error) {
795 795
 
796 796
 func getPullRequestByID(e Engine, id int64) (*PullRequest, error) {
797 797
 	pr := new(PullRequest)
798
-	has, err := e.Id(id).Get(pr)
798
+	has, err := e.ID(id).Get(pr)
799 799
 	if err != nil {
800 800
 		return nil, err
801 801
 	} else if !has {
@@ -829,13 +829,13 @@ func GetPullRequestByIssueID(issueID int64) (*PullRequest, error) {
829 829
 
830 830
 // Update updates all fields of pull request.
831 831
 func (pr *PullRequest) Update() error {
832
-	_, err := x.Id(pr.ID).AllCols().Update(pr)
832
+	_, err := x.ID(pr.ID).AllCols().Update(pr)
833 833
 	return err
834 834
 }
835 835
 
836 836
 // UpdateCols updates specific fields of pull request.
837 837
 func (pr *PullRequest) UpdateCols(cols ...string) error {
838
-	_, err := x.Id(pr.ID).Cols(cols...).Update(pr)
838
+	_, err := x.ID(pr.ID).Cols(cols...).Update(pr)
839 839
 	return err
840 840
 }
841 841
 

+ 5 - 5
models/release.go

@@ -170,7 +170,7 @@ func addReleaseAttachments(releaseID int64, attachmentUUIDs []string) (err error
170 170
 	for i := range attachments {
171 171
 		attachments[i].ReleaseID = releaseID
172 172
 		// No assign value could be 0, so ignore AllCols().
173
-		if _, err = x.Id(attachments[i].ID).Update(attachments[i]); err != nil {
173
+		if _, err = x.ID(attachments[i].ID).Update(attachments[i]); err != nil {
174 174
 			return fmt.Errorf("update attachment [%d]: %v", attachments[i].ID, err)
175 175
 		}
176 176
 	}
@@ -220,7 +220,7 @@ func GetRelease(repoID int64, tagName string) (*Release, error) {
220 220
 func GetReleaseByID(id int64) (*Release, error) {
221 221
 	rel := new(Release)
222 222
 	has, err := x.
223
-		Id(id).
223
+		ID(id).
224 224
 		Get(rel)
225 225
 	if err != nil {
226 226
 		return nil, err
@@ -365,7 +365,7 @@ func UpdateRelease(gitRepo *git.Repository, rel *Release, attachmentUUIDs []stri
365 365
 	}
366 366
 	rel.LowerTagName = strings.ToLower(rel.TagName)
367 367
 
368
-	_, err = x.Id(rel.ID).AllCols().Update(rel)
368
+	_, err = x.ID(rel.ID).AllCols().Update(rel)
369 369
 	if err != nil {
370 370
 		return err
371 371
 	}
@@ -402,7 +402,7 @@ func DeleteReleaseByID(id int64, u *User, delTag bool) error {
402 402
 			return fmt.Errorf("git tag -d: %v - %s", err, stderr)
403 403
 		}
404 404
 
405
-		if _, err = x.Id(rel.ID).Delete(new(Release)); err != nil {
405
+		if _, err = x.ID(rel.ID).Delete(new(Release)); err != nil {
406 406
 			return fmt.Errorf("Delete: %v", err)
407 407
 		}
408 408
 	} else {
@@ -412,7 +412,7 @@ func DeleteReleaseByID(id int64, u *User, delTag bool) error {
412 412
 		rel.Title = ""
413 413
 		rel.Note = ""
414 414
 
415
-		if _, err = x.Id(rel.ID).AllCols().Update(rel); err != nil {
415
+		if _, err = x.ID(rel.ID).AllCols().Update(rel); err != nil {
416 416
 			return fmt.Errorf("Update: %v", err)
417 417
 		}
418 418
 	}

+ 6 - 6
models/repo.go

@@ -620,7 +620,7 @@ func (repo *Repository) updateSize(e Engine) error {
620 620
 	}
621 621
 
622 622
 	repo.Size = repoInfoSize.Size + repoInfoSize.SizePack
623
-	_, err = e.Id(repo.ID).Cols("size").Update(repo)
623
+	_, err = e.ID(repo.ID).Cols("size").Update(repo)
624 624
 	return err
625 625
 }
626 626
 
@@ -1417,7 +1417,7 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error
1417 1417
 	repo.Owner = newOwner
1418 1418
 
1419 1419
 	// Update repository.
1420
-	if _, err := sess.Id(repo.ID).Update(repo); err != nil {
1420
+	if _, err := sess.ID(repo.ID).Update(repo); err != nil {
1421 1421
 		return fmt.Errorf("update owner: %v", err)
1422 1422
 	}
1423 1423
 
@@ -1449,7 +1449,7 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error
1449 1449
 			}
1450 1450
 
1451 1451
 			t.NumRepos--
1452
-			if _, err := sess.Id(t.ID).Cols("num_repos").Update(t); err != nil {
1452
+			if _, err := sess.ID(t.ID).Cols("num_repos").Update(t); err != nil {
1453 1453
 				return fmt.Errorf("decrease team repository count '%d': %v", t.ID, err)
1454 1454
 			}
1455 1455
 		}
@@ -1568,7 +1568,7 @@ func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err e
1568 1568
 		repo.Website = repo.Website[:255]
1569 1569
 	}
1570 1570
 
1571
-	if _, err = e.Id(repo.ID).AllCols().Update(repo); err != nil {
1571
+	if _, err = e.ID(repo.ID).AllCols().Update(repo); err != nil {
1572 1572
 		return fmt.Errorf("update: %v", err)
1573 1573
 	}
1574 1574
 
@@ -1687,7 +1687,7 @@ func DeleteRepository(doer *User, uid, repoID int64) error {
1687 1687
 		return ErrRepoNotExist{repoID, uid, ""}
1688 1688
 	}
1689 1689
 
1690
-	if cnt, err := sess.Id(repoID).Delete(&Repository{}); err != nil {
1690
+	if cnt, err := sess.ID(repoID).Delete(&Repository{}); err != nil {
1691 1691
 		return err
1692 1692
 	} else if cnt != 1 {
1693 1693
 		return ErrRepoNotExist{repoID, uid, ""}
@@ -1868,7 +1868,7 @@ func GetRepositoryByName(ownerID int64, name string) (*Repository, error) {
1868 1868
 
1869 1869
 func getRepositoryByID(e Engine, id int64) (*Repository, error) {
1870 1870
 	repo := new(Repository)
1871
-	has, err := e.Id(id).Get(repo)
1871
+	has, err := e.ID(id).Get(repo)
1872 1872
 	if err != nil {
1873 1873
 		return nil, err
1874 1874
 	} else if !has {

+ 1 - 1
models/repo_mirror.go

@@ -199,7 +199,7 @@ func GetMirrorByRepoID(repoID int64) (*Mirror, error) {
199 199
 }
200 200
 
201 201
 func updateMirror(e Engine, m *Mirror) error {
202
-	_, err := e.Id(m.ID).AllCols().Update(m)
202
+	_, err := e.ID(m.ID).AllCols().Update(m)
203 203
 	return err
204 204
 }
205 205
 

+ 3 - 3
models/ssh_key.go

@@ -722,7 +722,7 @@ func AddDeployKey(repoID int64, name, content string) (*DeployKey, error) {
722 722
 // GetDeployKeyByID returns deploy key by given ID.
723 723
 func GetDeployKeyByID(id int64) (*DeployKey, error) {
724 724
 	key := new(DeployKey)
725
-	has, err := x.Id(id).Get(key)
725
+	has, err := x.ID(id).Get(key)
726 726
 	if err != nil {
727 727
 		return nil, err
728 728
 	} else if !has {
@@ -748,7 +748,7 @@ func GetDeployKeyByRepo(keyID, repoID int64) (*DeployKey, error) {
748 748
 
749 749
 // UpdateDeployKey updates deploy key information.
750 750
 func UpdateDeployKey(key *DeployKey) error {
751
-	_, err := x.Id(key.ID).AllCols().Update(key)
751
+	_, err := x.ID(key.ID).AllCols().Update(key)
752 752
 	return err
753 753
 }
754 754
 
@@ -782,7 +782,7 @@ func DeleteDeployKey(doer *User, id int64) error {
782 782
 		return err
783 783
 	}
784 784
 
785
-	if _, err = sess.Id(key.ID).Delete(new(DeployKey)); err != nil {
785
+	if _, err = sess.ID(key.ID).Delete(new(DeployKey)); err != nil {
786 786
 		return fmt.Errorf("delete deploy key [%d]: %v", key.ID, err)
787 787
 	}
788 788
 

+ 2 - 2
models/token.go

@@ -68,13 +68,13 @@ func ListAccessTokens(uid int64) ([]*AccessToken, error) {
68 68
 
69 69
 // UpdateAccessToken updates information of access token.
70 70
 func UpdateAccessToken(t *AccessToken) error {
71
-	_, err := x.Id(t.ID).AllCols().Update(t)
71
+	_, err := x.ID(t.ID).AllCols().Update(t)
72 72
 	return err
73 73
 }
74 74
 
75 75
 // DeleteAccessTokenByID deletes access token by given ID.
76 76
 func DeleteAccessTokenByID(id, userID int64) error {
77
-	cnt, err := x.Id(id).Delete(&AccessToken{
77
+	cnt, err := x.ID(id).Delete(&AccessToken{
78 78
 		UID: userID,
79 79
 	})
80 80
 	if err != nil {

+ 2 - 2
models/twofactor.go

@@ -95,7 +95,7 @@ func NewTwoFactor(t *TwoFactor) error {
95 95
 
96 96
 // UpdateTwoFactor updates a two-factor authentication token.
97 97
 func UpdateTwoFactor(t *TwoFactor) error {
98
-	_, err := x.Id(t.ID).AllCols().Update(t)
98
+	_, err := x.ID(t.ID).AllCols().Update(t)
99 99
 	return err
100 100
 }
101 101
 
@@ -114,7 +114,7 @@ func GetTwoFactorByUID(uid int64) (*TwoFactor, error) {
114 114
 
115 115
 // DeleteTwoFactorByID deletes two-factor authentication token by given ID.
116 116
 func DeleteTwoFactorByID(id, userID int64) error {
117
-	cnt, err := x.Id(id).Delete(&TwoFactor{
117
+	cnt, err := x.ID(id).Delete(&TwoFactor{
118 118
 		UID: userID,
119 119
 	})
120 120
 	if err != nil {

+ 3 - 3
models/update.go

@@ -90,14 +90,14 @@ func pushUpdateDeleteTag(repo *Repository, gitRepo *git.Repository, tagName stri
90 90
 		return fmt.Errorf("GetRelease: %v", err)
91 91
 	}
92 92
 	if rel.IsTag {
93
-		if _, err = x.Id(rel.ID).Delete(new(Release)); err != nil {
93
+		if _, err = x.ID(rel.ID).Delete(new(Release)); err != nil {
94 94
 			return fmt.Errorf("Delete: %v", err)
95 95
 		}
96 96
 	} else {
97 97
 		rel.IsDraft = true
98 98
 		rel.NumCommits = 0
99 99
 		rel.Sha1 = ""
100
-		if _, err = x.Id(rel.ID).AllCols().Update(rel); err != nil {
100
+		if _, err = x.ID(rel.ID).AllCols().Update(rel); err != nil {
101 101
 			return fmt.Errorf("Update: %v", err)
102 102
 		}
103 103
 	}
@@ -161,7 +161,7 @@ func pushUpdateAddTag(repo *Repository, gitRepo *git.Repository, tagName string)
161 161
 		if rel.IsTag && author != nil {
162 162
 			rel.PublisherID = author.ID
163 163
 		}
164
-		if _, err = x.Id(rel.ID).AllCols().Update(rel); err != nil {
164
+		if _, err = x.ID(rel.ID).AllCols().Update(rel); err != nil {
165 165
 			return fmt.Errorf("Update: %v", err)
166 166
 		}
167 167
 	}

+ 6 - 6
models/user.go

@@ -302,7 +302,7 @@ func (u *User) generateRandomAvatar(e Engine) error {
302 302
 	}
303 303
 	defer fw.Close()
304 304
 
305
-	if _, err := e.Id(u.ID).Cols("avatar").Update(u); err != nil {
305
+	if _, err := e.ID(u.ID).Cols("avatar").Update(u); err != nil {
306 306
 		return err
307 307
 	}
308 308
 
@@ -459,7 +459,7 @@ func (u *User) DeleteAvatar() error {
459 459
 
460 460
 	u.UseCustomAvatar = false
461 461
 	u.Avatar = ""
462
-	if _, err := x.Id(u.ID).Cols("avatar, use_custom_avatar").Update(u); err != nil {
462
+	if _, err := x.ID(u.ID).Cols("avatar, use_custom_avatar").Update(u); err != nil {
463 463
 		return fmt.Errorf("UpdateUser: %v", err)
464 464
 	}
465 465
 	return nil
@@ -862,7 +862,7 @@ func updateUser(e Engine, u *User) error {
862 862
 	u.Website = base.TruncateString(u.Website, 255)
863 863
 	u.Description = base.TruncateString(u.Description, 255)
864 864
 
865
-	_, err := e.Id(u.ID).AllCols().Update(u)
865
+	_, err := e.ID(u.ID).AllCols().Update(u)
866 866
 	return err
867 867
 }
868 868
 
@@ -893,7 +893,7 @@ func updateUserCols(e Engine, u *User, cols ...string) error {
893 893
 	u.Website = base.TruncateString(u.Website, 255)
894 894
 	u.Description = base.TruncateString(u.Description, 255)
895 895
 
896
-	_, err := e.Id(u.ID).Cols(cols...).Update(u)
896
+	_, err := e.ID(u.ID).Cols(cols...).Update(u)
897 897
 	return err
898 898
 }
899 899
 
@@ -1019,7 +1019,7 @@ func deleteUser(e *xorm.Session, u *User) error {
1019 1019
 	}
1020 1020
 	// ***** END: ExternalLoginUser *****
1021 1021
 
1022
-	if _, err = e.Id(u.ID).Delete(new(User)); err != nil {
1022
+	if _, err = e.ID(u.ID).Delete(new(User)); err != nil {
1023 1023
 		return fmt.Errorf("Delete: %v", err)
1024 1024
 	}
1025 1025
 
@@ -1112,7 +1112,7 @@ func GetUserByKeyID(keyID int64) (*User, error) {
1112 1112
 
1113 1113
 func getUserByID(e Engine, id int64) (*User, error) {
1114 1114
 	u := new(User)
1115
-	has, err := e.Id(id).Get(u)
1115
+	has, err := e.ID(id).Get(u)
1116 1116
 	if err != nil {
1117 1117
 		return nil, err
1118 1118
 	} else if !has {

+ 2 - 2
models/user_mail.go

@@ -153,7 +153,7 @@ func DeleteEmailAddress(email *EmailAddress) (err error) {
153 153
 		UID: email.UID,
154 154
 	}
155 155
 	if email.ID > 0 {
156
-		deleted, err = x.Id(email.ID).Delete(&address)
156
+		deleted, err = x.ID(email.ID).Delete(&address)
157 157
 	} else {
158 158
 		deleted, err = x.
159 159
 			Where("email=?", email.Email).
@@ -222,7 +222,7 @@ func MakeEmailPrimary(email *EmailAddress) error {
222 222
 	}
223 223
 
224 224
 	user.Email = email.Email
225
-	if _, err = sess.Id(user.ID).Cols("email").Update(user); err != nil {
225
+	if _, err = sess.ID(user.ID).Cols("email").Update(user); err != nil {
226 226
 		return err
227 227
 	}
228 228
 

+ 1 - 1
models/user_openid.go

@@ -76,7 +76,7 @@ func DeleteUserOpenID(openid *UserOpenID) (err error) {
76 76
 		UID: openid.UID,
77 77
 	}
78 78
 	if openid.ID > 0 {
79
-		deleted, err = x.Id(openid.ID).Delete(&address)
79
+		deleted, err = x.ID(openid.ID).Delete(&address)
80 80
 	} else {
81 81
 		deleted, err = x.
82 82
 			Where("openid=?", openid.URI).

+ 2 - 2
models/webhook.go

@@ -270,7 +270,7 @@ func GetWebhooksByOrgID(orgID int64) (ws []*Webhook, err error) {
270 270
 
271 271
 // UpdateWebhook updates information of webhook.
272 272
 func UpdateWebhook(w *Webhook) error {
273
-	_, err := x.Id(w.ID).AllCols().Update(w)
273
+	_, err := x.ID(w.ID).AllCols().Update(w)
274 274
 	return err
275 275
 }
276 276
 
@@ -477,7 +477,7 @@ func createHookTask(e Engine, t *HookTask) error {
477 477
 
478 478
 // UpdateHookTask updates information of hook task.
479 479
 func UpdateHookTask(t *HookTask) error {
480
-	_, err := x.Id(t.ID).AllCols().Update(t)
480
+	_, err := x.ID(t.ID).AllCols().Update(t)
481 481
 	return err
482 482
 }
483 483