From 77275a9b311ed126f887628f33fbd917750420cd Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 16 Aug 2018 20:26:09 +0800 Subject: [PATCH] models: rename Id to ID --- models/comment.go | 2 +- models/issue.go | 8 ++++---- models/issue_label.go | 4 ++-- models/migrations/migrations.go | 2 +- models/milestone.go | 8 ++++---- models/mirror.go | 2 +- models/models.go | 2 +- models/org.go | 2 +- models/org_team.go | 20 ++++++++++---------- models/pull.go | 4 ++-- models/release.go | 2 +- models/repo.go | 8 ++++---- models/repo_branch.go | 4 ++-- models/repo_collaboration.go | 2 +- models/ssh_key.go | 2 +- models/user.go | 4 ++-- models/user_mail.go | 4 ++-- 17 files changed, 40 insertions(+), 40 deletions(-) diff --git a/models/comment.go b/models/comment.go index 66531bbb3..67fc2511b 100644 --- a/models/comment.go +++ b/models/comment.go @@ -500,7 +500,7 @@ func DeleteCommentByID(doer *User, id int64) error { return err } - if _, err = sess.Id(comment.ID).Delete(new(Comment)); err != nil { + if _, err = sess.ID(comment.ID).Delete(new(Comment)); err != nil { return err } diff --git a/models/issue.go b/models/issue.go index 2d0f06abb..de87080ad 100644 --- a/models/issue.go +++ b/models/issue.go @@ -402,7 +402,7 @@ func (i *Issue) ReadBy(uid int64) error { } func updateIssueCols(e Engine, issue *Issue, cols ...string) error { - _, err := e.Id(issue.ID).Cols(cols...).Update(issue) + _, err := e.ID(issue.ID).Cols(cols...).Update(issue) return err } @@ -843,7 +843,7 @@ func GetIssueByIndex(repoID, index int64) (*Issue, error) { func getRawIssueByID(e Engine, id int64) (*Issue, error) { issue := new(Issue) - has, err := e.Id(id).Get(issue) + has, err := e.ID(id).Get(issue) if err != nil { return nil, err } else if !has { @@ -1354,7 +1354,7 @@ func GetRepoIssueStats(repoID, userID int64, filterMode FilterMode, isPull bool) } func updateIssue(e Engine, issue *Issue) error { - _, err := e.Id(issue.ID).AllCols().Update(issue) + _, err := e.ID(issue.ID).AllCols().Update(issue) return err } @@ -1423,7 +1423,7 @@ func updateIssueUsersByMentions(e Engine, issueID int64, uids []int64) error { iu.IsMentioned = true if has { - _, err = e.Id(iu.ID).AllCols().Update(iu) + _, err = e.ID(iu.ID).AllCols().Update(iu) } else { _, err = e.Insert(iu) } diff --git a/models/issue_label.go b/models/issue_label.go index bec1cb1f9..0587ca1f9 100644 --- a/models/issue_label.go +++ b/models/issue_label.go @@ -196,7 +196,7 @@ func GetLabelsByIssueID(issueID int64) ([]*Label, error) { } func updateLabel(e Engine, l *Label) error { - _, err := e.Id(l.ID).AllCols().Update(l) + _, err := e.ID(l.ID).AllCols().Update(l) return err } @@ -221,7 +221,7 @@ func DeleteLabel(repoID, labelID int64) error { return err } - if _, err = sess.Id(labelID).Delete(new(Label)); err != nil { + if _, err = sess.ID(labelID).Delete(new(Label)); err != nil { return err } else if _, err = sess.Where("label_id = ?", labelID).Delete(new(IssueLabel)); err != nil { return err diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 44496a155..3d3327ef4 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -162,7 +162,7 @@ func generateOrgRandsAndSalt(x *xorm.Engine) (err error) { if org.Salt, err = tool.RandomString(10); err != nil { return err } - if _, err = sess.Id(org.ID).Update(org); err != nil { + if _, err = sess.ID(org.ID).Update(org); err != nil { return err } } diff --git a/models/milestone.go b/models/milestone.go index 0488e03a7..f05e33165 100644 --- a/models/milestone.go +++ b/models/milestone.go @@ -166,7 +166,7 @@ func GetMilestones(repoID int64, page int, isClosed bool) ([]*Milestone, error) } func updateMilestone(e Engine, m *Milestone) error { - _, err := e.Id(m.ID).AllCols().Update(m) + _, err := e.ID(m.ID).AllCols().Update(m) return err } @@ -223,7 +223,7 @@ func ChangeMilestoneStatus(m *Milestone, isClosed bool) (err error) { repo.NumMilestones = int(countRepoMilestones(sess, repo.ID)) repo.NumClosedMilestones = int(countRepoClosedMilestones(sess, repo.ID)) - if _, err = sess.Id(repo.ID).AllCols().Update(repo); err != nil { + if _, err = sess.ID(repo.ID).AllCols().Update(repo); err != nil { return err } return sess.Commit() @@ -383,13 +383,13 @@ func DeleteMilestoneOfRepoByID(repoID, id int64) error { return err } - if _, err = sess.Id(m.ID).Delete(new(Milestone)); err != nil { + if _, err = sess.ID(m.ID).Delete(new(Milestone)); err != nil { return err } repo.NumMilestones = int(countRepoMilestones(sess, repo.ID)) repo.NumClosedMilestones = int(countRepoClosedMilestones(sess, repo.ID)) - if _, err = sess.Id(repo.ID).AllCols().Update(repo); err != nil { + if _, err = sess.ID(repo.ID).AllCols().Update(repo); err != nil { return err } diff --git a/models/mirror.go b/models/mirror.go index da6b7f2b6..653079ea3 100644 --- a/models/mirror.go +++ b/models/mirror.go @@ -320,7 +320,7 @@ func GetMirrorByRepoID(repoID int64) (*Mirror, error) { } func updateMirror(e Engine, m *Mirror) error { - _, err := e.Id(m.ID).AllCols().Update(m) + _, err := e.ID(m.ID).AllCols().Update(m) return err } diff --git a/models/models.go b/models/models.go index 6407f4134..5cd7e5279 100644 --- a/models/models.go +++ b/models/models.go @@ -33,7 +33,7 @@ type Engine interface { Exec(string, ...interface{}) (sql.Result, error) Find(interface{}, ...interface{}) error Get(interface{}) (bool, error) - Id(interface{}) *xorm.Session + ID(interface{}) *xorm.Session In(string, ...interface{}) *xorm.Session Insert(...interface{}) (int64, error) InsertOne(interface{}) (int64, error) diff --git a/models/org.go b/models/org.go index 6414596b6..f5967cea4 100644 --- a/models/org.go +++ b/models/org.go @@ -410,7 +410,7 @@ func RemoveOrgUser(orgID, userID int64) error { return err } - if _, err := sess.Id(ou.ID).Delete(ou); err != nil { + if _, err := sess.ID(ou.ID).Delete(ou); err != nil { return err } else if _, err = sess.Exec("UPDATE `user` SET num_members=num_members-1 WHERE id=?", orgID); err != nil { return err diff --git a/models/org_team.go b/models/org_team.go index 709db547d..fc06d6601 100644 --- a/models/org_team.go +++ b/models/org_team.go @@ -111,7 +111,7 @@ func (t *Team) addRepository(e Engine, repo *Repository) (err error) { } t.NumRepos++ - if _, err = e.Id(t.ID).AllCols().Update(t); err != nil { + if _, err = e.ID(t.ID).AllCols().Update(t); err != nil { return fmt.Errorf("update team: %v", err) } @@ -157,7 +157,7 @@ func (t *Team) removeRepository(e Engine, repo *Repository, recalculate bool) (e } t.NumRepos-- - if _, err = e.Id(t.ID).AllCols().Update(t); err != nil { + if _, err = e.ID(t.ID).AllCols().Update(t); err != nil { return err } @@ -286,7 +286,7 @@ func GetTeamOfOrgByName(orgID int64, name string) (*Team, error) { func getTeamByID(e Engine, teamID int64) (*Team, error) { t := new(Team) - has, err := e.Id(teamID).Get(t) + has, err := e.ID(teamID).Get(t) if err != nil { return nil, err } else if !has { @@ -334,7 +334,7 @@ func UpdateTeam(t *Team, authChanged bool) (err error) { return ErrTeamAlreadyExist{t.OrgID, t.LowerName} } - if _, err = sess.Id(t.ID).AllCols().Update(t); err != nil { + if _, err = sess.ID(t.ID).AllCols().Update(t); err != nil { return fmt.Errorf("update: %v", err) } @@ -386,7 +386,7 @@ func DeleteTeam(t *Team) error { } // Delete team. - if _, err = sess.Id(t.ID).Delete(new(Team)); err != nil { + if _, err = sess.ID(t.ID).Delete(new(Team)); err != nil { return err } // Update organization number of teams. @@ -431,7 +431,7 @@ func getTeamMembers(e Engine, teamID int64) (_ []*User, err error) { members := make([]*User, 0, len(teamUsers)) for i := range teamUsers { member := new(User) - if _, err = e.Id(teamUsers[i].UID).Get(member); err != nil { + if _, err = e.ID(teamUsers[i].UID).Get(member); err != nil { return nil, fmt.Errorf("get user '%d': %v", teamUsers[i].UID, err) } members = append(members, member) @@ -500,7 +500,7 @@ func AddTeamMember(orgID, teamID, userID int64) error { } if _, err = sess.Insert(tu); err != nil { return err - } else if _, err = sess.Id(t.ID).Update(t); err != nil { + } else if _, err = sess.ID(t.ID).Update(t); err != nil { return err } @@ -520,7 +520,7 @@ func AddTeamMember(orgID, teamID, userID int64) error { if t.IsOwnerTeam() { ou.IsOwner = true } - if _, err = sess.Id(ou.ID).AllCols().Update(ou); err != nil { + if _, err = sess.ID(ou.ID).AllCols().Update(ou); err != nil { return err } @@ -562,7 +562,7 @@ func removeTeamMember(e Engine, orgID, teamID, uid int64) error { } if _, err := e.Delete(tu); err != nil { return err - } else if _, err = e.Id(t.ID).AllCols().Update(t); err != nil { + } else if _, err = e.ID(t.ID).AllCols().Update(t); err != nil { return err } @@ -583,7 +583,7 @@ func removeTeamMember(e Engine, orgID, teamID, uid int64) error { if t.IsOwnerTeam() { ou.IsOwner = false } - if _, err = e.Id(ou.ID).AllCols().Update(ou); err != nil { + if _, err = e.ID(ou.ID).AllCols().Update(ou); err != nil { return err } return nil diff --git a/models/pull.go b/models/pull.go index 9dd8737f0..3a80cbc11 100644 --- a/models/pull.go +++ b/models/pull.go @@ -321,7 +321,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle pr.HasMerged = true pr.Merged = time.Now() pr.MergerID = doer.ID - if _, err = sess.Id(pr.ID).AllCols().Update(pr); err != nil { + if _, err = sess.ID(pr.ID).AllCols().Update(pr); err != nil { return fmt.Errorf("update pull request: %v", err) } @@ -546,7 +546,7 @@ func GetUnmergedPullRequestsByBaseInfo(repoID int64, branch string) ([]*PullRequ func getPullRequestByID(e Engine, id int64) (*PullRequest, error) { pr := new(PullRequest) - has, err := e.Id(id).Get(pr) + has, err := e.ID(id).Get(pr) if err != nil { return nil, err } else if !has { diff --git a/models/release.go b/models/release.go index 65f854318..c968502c1 100644 --- a/models/release.go +++ b/models/release.go @@ -293,7 +293,7 @@ func UpdateRelease(doer *User, gitRepo *git.Repository, r *Release, isPublish bo if err = sess.Begin(); err != nil { return err } - if _, err = sess.Id(r.ID).AllCols().Update(r); err != nil { + if _, err = sess.ID(r.ID).AllCols().Update(r); err != nil { return fmt.Errorf("Update: %v", err) } diff --git a/models/repo.go b/models/repo.go index c9c1964ae..eefaa6b17 100644 --- a/models/repo.go +++ b/models/repo.go @@ -1264,7 +1264,7 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error repo.Owner = newOwner // Update repository. - if _, err := sess.Id(repo.ID).Update(repo); err != nil { + if _, err := sess.ID(repo.ID).Update(repo); err != nil { return fmt.Errorf("update owner: %v", err) } @@ -1296,7 +1296,7 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error } t.NumRepos-- - if _, err := sess.Id(t.ID).AllCols().Update(t); err != nil { + if _, err := sess.ID(t.ID).AllCols().Update(t); err != nil { return fmt.Errorf("decrease team repository count '%d': %v", t.ID, err) } } @@ -1409,7 +1409,7 @@ func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err e repo.Website = repo.Website[:255] } - if _, err = e.Id(repo.ID).AllCols().Update(repo); err != nil { + if _, err = e.ID(repo.ID).AllCols().Update(repo); err != nil { return fmt.Errorf("update: %v", err) } @@ -1625,7 +1625,7 @@ func GetRepositoryByName(ownerID int64, name string) (*Repository, error) { func getRepositoryByID(e Engine, id int64) (*Repository, error) { repo := new(Repository) - has, err := e.Id(id).Get(repo) + has, err := e.ID(id).Get(repo) if err != nil { return nil, err } else if !has { diff --git a/models/repo_branch.go b/models/repo_branch.go index 1d98fd12a..24046d6fd 100644 --- a/models/repo_branch.go +++ b/models/repo_branch.go @@ -131,7 +131,7 @@ func UpdateProtectBranch(protectBranch *ProtectBranch) (err error) { } } - if _, err = sess.Id(protectBranch.ID).AllCols().Update(protectBranch); err != nil { + if _, err = sess.ID(protectBranch.ID).AllCols().Update(protectBranch); err != nil { return fmt.Errorf("Update: %v", err) } @@ -234,7 +234,7 @@ func UpdateOrgProtectBranch(repo *Repository, protectBranch *ProtectBranch, whit return err } - if _, err = sess.Id(protectBranch.ID).AllCols().Update(protectBranch); err != nil { + if _, err = sess.ID(protectBranch.ID).AllCols().Update(protectBranch); err != nil { return fmt.Errorf("Update: %v", err) } diff --git a/models/repo_collaboration.go b/models/repo_collaboration.go index 107e1c5aa..189d0c3f5 100644 --- a/models/repo_collaboration.go +++ b/models/repo_collaboration.go @@ -170,7 +170,7 @@ func (repo *Repository) ChangeCollaborationAccessMode(userID int64, mode AccessM return err } - if _, err = sess.Id(collaboration.ID).AllCols().Update(collaboration); err != nil { + if _, err = sess.ID(collaboration.ID).AllCols().Update(collaboration); err != nil { return fmt.Errorf("update collaboration: %v", err) } diff --git a/models/ssh_key.go b/models/ssh_key.go index 3d99f2070..4d08d1112 100644 --- a/models/ssh_key.go +++ b/models/ssh_key.go @@ -747,7 +747,7 @@ func DeleteDeployKey(doer *User, id int64) error { return err } - if _, err = sess.Id(key.ID).Delete(new(DeployKey)); err != nil { + if _, err = sess.ID(key.ID).Delete(new(DeployKey)); err != nil { return fmt.Errorf("delete deploy key [%d]: %v", key.ID, err) } diff --git a/models/user.go b/models/user.go index 7e014df43..d607806a8 100644 --- a/models/user.go +++ b/models/user.go @@ -706,7 +706,7 @@ func updateUser(e Engine, u *User) error { u.Website = tool.TruncateString(u.Website, 255) u.Description = tool.TruncateString(u.Description, 255) - _, err := e.Id(u.ID).AllCols().Update(u) + _, err := e.ID(u.ID).AllCols().Update(u) return err } @@ -890,7 +890,7 @@ func GetUserByKeyID(keyID int64) (*User, error) { func getUserByID(e Engine, id int64) (*User, error) { u := new(User) - has, err := e.Id(id).Get(u) + has, err := e.ID(id).Get(u) if err != nil { return nil, err } else if !has { diff --git a/models/user_mail.go b/models/user_mail.go index 46197490f..cc48ace8e 100644 --- a/models/user_mail.go +++ b/models/user_mail.go @@ -132,7 +132,7 @@ func (email *EmailAddress) Activate() error { } email.IsActivated = true - if _, err := sess.Id(email.ID).AllCols().Update(email); err != nil { + if _, err := sess.ID(email.ID).AllCols().Update(email); err != nil { return err } else if err = updateUser(sess, user); err != nil { return err @@ -202,7 +202,7 @@ func MakeEmailPrimary(email *EmailAddress) error { } user.Email = email.Email - if _, err = sess.Id(user.ID).AllCols().Update(user); err != nil { + if _, err = sess.ID(user.ID).AllCols().Update(user); err != nil { return err }