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).Cols("num_milestones, num_closed_milestones").Update(repo); err != nil {
return err
}
return sess.Commit()
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).Cols("num_milestones, num_closed_milestones").Update(repo); err != nil {
return err
}
iu.IsMentioned = true
if has {
- _, err = e.Id(iu.ID).AllCols().Update(iu)
+ _, err = e.Id(iu.ID).Cols("is_mentioned").Update(iu)
} else {
_, err = e.Insert(iu)
}
}
ou.IsPublic = public
- _, err = x.Id(ou.ID).AllCols().Update(ou)
+ _, err = x.Id(ou.ID).Cols("is_public").Update(ou)
return err
}
}
t.NumRepos++
- if _, err = e.Id(t.ID).AllCols().Update(t); err != nil {
+ if _, err = e.Id(t.ID).Cols("num_repos").Update(t); err != nil {
return fmt.Errorf("update team: %v", err)
}
}
t.NumRepos--
- if _, err = e.Id(t.ID).AllCols().Update(t); err != nil {
+ if _, err = e.Id(t.ID).Cols("num_repos").Update(t); err != nil {
return err
}
if team.IsOwnerTeam() {
ou.IsOwner = true
}
- if _, err := sess.Id(ou.ID).AllCols().Update(ou); err != nil {
+ if _, err := sess.Id(ou.ID).Cols("num_teams, is_owner").Update(ou); err != nil {
return err
}
return err
} else if _, err = e.
Id(team.ID).
- AllCols().
+ Cols("num_members").
Update(team); err != nil {
return err
}
}
if _, err = e.
Id(ou.ID).
- AllCols().
+ Cols("num_teams").
Update(ou); err != nil {
return err
}
if err = pr.Issue.changeStatus(sess, pr.Merger, pr.Issue.Repo, true); err != nil {
return fmt.Errorf("Issue.changeStatus: %v", err)
}
- if _, err = sess.Id(pr.ID).AllCols().Update(pr); err != nil {
+ if _, err = sess.Id(pr.ID).Cols("has_merged").Update(pr); err != nil {
return fmt.Errorf("update pull request: %v", err)
}
}
t.NumRepos--
- if _, err := sess.Id(t.ID).AllCols().Update(t); err != nil {
+ if _, err := sess.Id(t.ID).Cols("num_repos").Update(t); err != nil {
return fmt.Errorf("decrease team repository count '%d': %v", t.ID, err)
}
}
if _, err = sess.
Id(collaboration.ID).
- AllCols().
+ Cols("mode").
Update(collaboration); err != nil {
return fmt.Errorf("update collaboration: %v", err)
} else if _, err = sess.Exec("UPDATE access SET mode = ? WHERE user_id = ? AND repo_id = ?", mode, uid, repo.ID); err != nil {
Find(&keys)
}
-// UpdatePublicKey updates given public key.
-func UpdatePublicKey(key *PublicKey) error {
- _, err := x.Id(key.ID).AllCols().Update(key)
- return err
-}
-
// UpdatePublicKeyUpdated updates public key use time.
func UpdatePublicKeyUpdated(id int64) error {
- now := time.Now()
// Check if key exists before update as affected rows count is unreliable
// and will return 0 affected rows if two updates are made at the same time
if cnt, err := x.ID(id).Count(&PublicKey{}); err != nil {
}
_, err := x.ID(id).Cols("updated_unix").Update(&PublicKey{
- Updated: now,
- UpdatedUnix: now.Unix(),
+ UpdatedUnix: time.Now().Unix(),
})
if err != nil {
return err
// UpdateUserCols update user according special columns
func UpdateUserCols(u *User, cols ...string) error {
+ return updateUserCols(x, u, cols...)
+}
+
+func updateUserCols(e Engine, u *User, cols ...string) error {
// Organization does not need email
u.Email = strings.ToLower(u.Email)
if !u.IsOrganization() {
u.Website = base.TruncateString(u.Website, 255)
u.Description = base.TruncateString(u.Description, 255)
- _, err := x.Id(u.ID).Cols(cols...).Update(u)
+ _, err := e.Id(u.ID).Cols(cols...).Update(u)
return err
}
email.IsActivated = true
if _, err := sess.
Id(email.ID).
- AllCols().
+ Cols("is_activated").
Update(email); err != nil {
return err
- } else if err = updateUser(sess, user); err != nil {
+ } else if err = updateUserCols(sess, user, "rands"); err != nil {
return err
}
}
user.Email = email.Email
- if _, err = sess.Id(user.ID).AllCols().Update(user); err != nil {
+ if _, err = sess.Id(user.ID).Cols("email").Update(user); err != nil {
return err
}