mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-10 12:15:43 +01:00
Replace deprecated Id method with ID (#2655)
This commit is contained in:
parent
e1266a19c8
commit
aa962deec0
31 changed files with 84 additions and 84 deletions
|
@ -76,7 +76,7 @@ func TestRenameRepoAction(t *testing.T) {
|
||||||
assert.NoError(t, RenameRepoAction(user, oldRepoName, repo))
|
assert.NoError(t, RenameRepoAction(user, oldRepoName, repo))
|
||||||
AssertExistsAndLoadBean(t, actionBean)
|
AssertExistsAndLoadBean(t, actionBean)
|
||||||
|
|
||||||
_, err := x.Id(repo.ID).Cols("name", "lower_name").Update(repo)
|
_, err := x.ID(repo.ID).Cols("name", "lower_name").Update(repo)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
CheckConsistencyFor(t, &Action{})
|
CheckConsistencyFor(t, &Action{})
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ func TestTransferRepoAction(t *testing.T) {
|
||||||
assert.NoError(t, TransferRepoAction(user2, user2, repo))
|
assert.NoError(t, TransferRepoAction(user2, user2, repo))
|
||||||
AssertExistsAndLoadBean(t, actionBean)
|
AssertExistsAndLoadBean(t, actionBean)
|
||||||
|
|
||||||
_, err := x.Id(repo.ID).Cols("owner_id").Update(repo)
|
_, err := x.ID(repo.ID).Cols("owner_id").Update(repo)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
CheckConsistencyFor(t, &Action{})
|
CheckConsistencyFor(t, &Action{})
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ func Notices(page, pageSize int) ([]*Notice, error) {
|
||||||
|
|
||||||
// DeleteNotice deletes a system notice by given ID.
|
// DeleteNotice deletes a system notice by given ID.
|
||||||
func DeleteNotice(id int64) error {
|
func DeleteNotice(id int64) error {
|
||||||
_, err := x.Id(id).Delete(new(Notice))
|
_, err := x.ID(id).Delete(new(Notice))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ func UpdateProtectBranch(repo *Repository, protectBranch *ProtectedBranch, white
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err = x.Id(protectBranch.ID).AllCols().Update(protectBranch); err != nil {
|
if _, err = x.ID(protectBranch.ID).AllCols().Update(protectBranch); err != nil {
|
||||||
return fmt.Errorf("Update: %v", err)
|
return fmt.Errorf("Update: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ func ListGPGKeys(uid int64) ([]*GPGKey, error) {
|
||||||
// GetGPGKeyByID returns public key by given ID.
|
// GetGPGKeyByID returns public key by given ID.
|
||||||
func GetGPGKeyByID(keyID int64) (*GPGKey, error) {
|
func GetGPGKeyByID(keyID int64) (*GPGKey, error) {
|
||||||
key := new(GPGKey)
|
key := new(GPGKey)
|
||||||
has, err := x.Id(keyID).Get(key)
|
has, err := x.ID(keyID).Get(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
|
|
|
@ -570,7 +570,7 @@ func (issue *Issue) ReadBy(userID int64) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateIssueCols(e Engine, issue *Issue, cols ...string) error {
|
func updateIssueCols(e Engine, issue *Issue, cols ...string) error {
|
||||||
if _, err := e.Id(issue.ID).Cols(cols...).Update(issue); err != nil {
|
if _, err := e.ID(issue.ID).Cols(cols...).Update(issue); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
UpdateIssueIndexer(issue.ID)
|
UpdateIssueIndexer(issue.ID)
|
||||||
|
@ -911,7 +911,7 @@ func newIssue(e *xorm.Session, doer *User, opts NewIssueOptions) (err error) {
|
||||||
|
|
||||||
for i := 0; i < len(attachments); i++ {
|
for i := 0; i < len(attachments); i++ {
|
||||||
attachments[i].IssueID = opts.Issue.ID
|
attachments[i].IssueID = opts.Issue.ID
|
||||||
if _, err = e.Id(attachments[i].ID).Update(attachments[i]); err != nil {
|
if _, err = e.ID(attachments[i].ID).Update(attachments[i]); err != nil {
|
||||||
return fmt.Errorf("update attachment [id: %d]: %v", attachments[i].ID, err)
|
return fmt.Errorf("update attachment [id: %d]: %v", attachments[i].ID, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1008,7 +1008,7 @@ func GetIssueByIndex(repoID, index int64) (*Issue, error) {
|
||||||
|
|
||||||
func getIssueByID(e Engine, id int64) (*Issue, error) {
|
func getIssueByID(e Engine, id int64) (*Issue, error) {
|
||||||
issue := new(Issue)
|
issue := new(Issue)
|
||||||
has, err := e.Id(id).Get(issue)
|
has, err := e.ID(id).Get(issue)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
|
@ -1435,7 +1435,7 @@ func GetRepoIssueStats(repoID, uid int64, filterMode int, isPull bool) (numOpen
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateIssue(e Engine, issue *Issue) error {
|
func updateIssue(e Engine, issue *Issue) error {
|
||||||
_, err := e.Id(issue.ID).AllCols().Update(issue)
|
_, err := e.ID(issue.ID).AllCols().Update(issue)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -356,7 +356,7 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
|
||||||
attachments[i].IssueID = opts.Issue.ID
|
attachments[i].IssueID = opts.Issue.ID
|
||||||
attachments[i].CommentID = comment.ID
|
attachments[i].CommentID = comment.ID
|
||||||
// No assign value could be 0, so ignore AllCols().
|
// No assign value could be 0, so ignore AllCols().
|
||||||
if _, err = e.Id(attachments[i].ID).Update(attachments[i]); err != nil {
|
if _, err = e.ID(attachments[i].ID).Update(attachments[i]); err != nil {
|
||||||
return nil, fmt.Errorf("update attachment [%d]: %v", attachments[i].ID, err)
|
return nil, fmt.Errorf("update attachment [%d]: %v", attachments[i].ID, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -569,7 +569,7 @@ func CreateRefComment(doer *User, repo *Repository, issue *Issue, content, commi
|
||||||
// GetCommentByID returns the comment by given ID.
|
// GetCommentByID returns the comment by given ID.
|
||||||
func GetCommentByID(id int64) (*Comment, error) {
|
func GetCommentByID(id int64) (*Comment, error) {
|
||||||
c := new(Comment)
|
c := new(Comment)
|
||||||
has, err := x.Id(id).Get(c)
|
has, err := x.ID(id).Get(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
|
@ -647,7 +647,7 @@ func GetCommentsByRepoIDSince(repoID, since int64) ([]*Comment, error) {
|
||||||
|
|
||||||
// UpdateComment updates information of comment.
|
// UpdateComment updates information of comment.
|
||||||
func UpdateComment(c *Comment) error {
|
func UpdateComment(c *Comment) error {
|
||||||
if _, err := x.Id(c.ID).AllCols().Update(c); err != nil {
|
if _, err := x.ID(c.ID).AllCols().Update(c); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if c.Type == CommentTypeComment {
|
} else if c.Type == CommentTypeComment {
|
||||||
UpdateIssueIndexer(c.IssueID)
|
UpdateIssueIndexer(c.IssueID)
|
||||||
|
|
|
@ -222,7 +222,7 @@ func GetLabelsByIssueID(issueID int64) ([]*Label, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateLabel(e Engine, l *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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +247,7 @@ func DeleteLabel(repoID, labelID int64) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err = sess.Id(labelID).Delete(new(Label)); err != nil {
|
if _, err = sess.ID(labelID).Delete(new(Label)); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if _, err = sess.
|
} else if _, err = sess.
|
||||||
Where("label_id = ?", labelID).
|
Where("label_id = ?", labelID).
|
||||||
|
|
|
@ -165,7 +165,7 @@ func GetMilestones(repoID int64, page int, isClosed bool, sortType string) ([]*M
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateMilestone(e Engine, m *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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ func ChangeMilestoneStatus(m *Milestone, isClosed bool) (err error) {
|
||||||
|
|
||||||
repo.NumMilestones = int(countRepoMilestones(sess, repo.ID))
|
repo.NumMilestones = int(countRepoMilestones(sess, repo.ID))
|
||||||
repo.NumClosedMilestones = int(countRepoClosedMilestones(sess, repo.ID))
|
repo.NumClosedMilestones = int(countRepoClosedMilestones(sess, repo.ID))
|
||||||
if _, err = sess.Id(repo.ID).Cols("num_milestones, num_closed_milestones").Update(repo); err != nil {
|
if _, err = sess.ID(repo.ID).Cols("num_milestones, num_closed_milestones").Update(repo); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return sess.Commit()
|
return sess.Commit()
|
||||||
|
@ -329,13 +329,13 @@ func DeleteMilestoneByRepoID(repoID, id int64) error {
|
||||||
return err
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
repo.NumMilestones = int(countRepoMilestones(sess, repo.ID))
|
repo.NumMilestones = int(countRepoMilestones(sess, repo.ID))
|
||||||
repo.NumClosedMilestones = int(countRepoClosedMilestones(sess, repo.ID))
|
repo.NumClosedMilestones = int(countRepoClosedMilestones(sess, repo.ID))
|
||||||
if _, err = sess.Id(repo.ID).Cols("num_milestones, num_closed_milestones").Update(repo); err != nil {
|
if _, err = sess.ID(repo.ID).Cols("num_milestones, num_closed_milestones").Update(repo); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ func UpdateIssueUsersByMentions(e Engine, issueID int64, uids []int64) error {
|
||||||
|
|
||||||
iu.IsMentioned = true
|
iu.IsMentioned = true
|
||||||
if has {
|
if has {
|
||||||
_, err = e.Id(iu.ID).Cols("is_mentioned").Update(iu)
|
_, err = e.ID(iu.ID).Cols("is_mentioned").Update(iu)
|
||||||
} else {
|
} else {
|
||||||
_, err = e.Insert(iu)
|
_, err = e.Insert(iu)
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ func CreateOrUpdateIssueWatch(userID, issueID int64, isWatching bool) error {
|
||||||
} else {
|
} else {
|
||||||
iw.IsWatching = isWatching
|
iw.IsWatching = isWatching
|
||||||
|
|
||||||
if _, err := x.Id(iw.ID).Cols("is_watching", "updated_unix").Update(iw); err != nil {
|
if _, err := x.ID(iw.ID).Cols("is_watching", "updated_unix").Update(iw); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -308,7 +308,7 @@ func LoginSources() ([]*LoginSource, error) {
|
||||||
// GetLoginSourceByID returns login source by given ID.
|
// GetLoginSourceByID returns login source by given ID.
|
||||||
func GetLoginSourceByID(id int64) (*LoginSource, error) {
|
func GetLoginSourceByID(id int64) (*LoginSource, error) {
|
||||||
source := new(LoginSource)
|
source := new(LoginSource)
|
||||||
has, err := x.Id(id).Get(source)
|
has, err := x.ID(id).Get(source)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
|
@ -328,7 +328,7 @@ func UpdateSource(source *LoginSource) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := x.Id(source.ID).AllCols().Update(source)
|
_, err := x.ID(source.ID).AllCols().Update(source)
|
||||||
if err == nil && source.IsOAuth2() && source.IsActived {
|
if err == nil && source.IsOAuth2() && source.IsActived {
|
||||||
oAuth2Config := source.OAuth2()
|
oAuth2Config := source.OAuth2()
|
||||||
err = oauth2.RegisterProvider(source.Name, oAuth2Config.Provider, oAuth2Config.ClientID, oAuth2Config.ClientSecret, oAuth2Config.OpenIDConnectAutoDiscoveryURL, oAuth2Config.CustomURLMapping)
|
err = oauth2.RegisterProvider(source.Name, oAuth2Config.Provider, oAuth2Config.ClientID, oAuth2Config.ClientSecret, oAuth2Config.OpenIDConnectAutoDiscoveryURL, oAuth2Config.CustomURLMapping)
|
||||||
|
@ -336,7 +336,7 @@ func UpdateSource(source *LoginSource) error {
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// restore original values since we cannot update the provider it self
|
// restore original values since we cannot update the provider it self
|
||||||
x.Id(source.ID).AllCols().Update(originalLoginSource)
|
x.ID(source.ID).AllCols().Update(originalLoginSource)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
@ -362,7 +362,7 @@ func DeleteSource(source *LoginSource) error {
|
||||||
oauth2.RemoveProvider(source.Name)
|
oauth2.RemoveProvider(source.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = x.Id(source.ID).Delete(new(LoginSource))
|
_, err = x.ID(source.ID).Delete(new(LoginSource))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -647,7 +647,7 @@ func UserSignIn(username, password string) (*User, error) {
|
||||||
|
|
||||||
default:
|
default:
|
||||||
var source LoginSource
|
var source LoginSource
|
||||||
hasSource, err := x.Id(user.LoginSource).Get(&source)
|
hasSource, err := x.ID(user.LoginSource).Get(&source)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !hasSource {
|
} else if !hasSource {
|
||||||
|
|
|
@ -173,7 +173,7 @@ Please try to upgrade to a lower version (>= v0.6.0) first, then upgrade to curr
|
||||||
if int(v-minDBVersion) > len(migrations) {
|
if int(v-minDBVersion) > len(migrations) {
|
||||||
// User downgraded Gitea.
|
// User downgraded Gitea.
|
||||||
currentVersion.Version = int64(len(migrations) + minDBVersion)
|
currentVersion.Version = int64(len(migrations) + minDBVersion)
|
||||||
_, err = x.Id(1).Update(currentVersion)
|
_, err = x.ID(1).Update(currentVersion)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for i, m := range migrations[v-minDBVersion:] {
|
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
|
||||||
return fmt.Errorf("do migrate: %v", err)
|
return fmt.Errorf("do migrate: %v", err)
|
||||||
}
|
}
|
||||||
currentVersion.Version = v + int64(i) + 1
|
currentVersion.Version = v + int64(i) + 1
|
||||||
if _, err = x.Id(1).Update(currentVersion); err != nil {
|
if _, err = x.ID(1).Update(currentVersion); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ func addRepoSize(x *xorm.Engine) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
repo.Size = countObject.Size + countObject.SizePack
|
repo.Size = countObject.Size + countObject.SizePack
|
||||||
if _, err = x.Id(repo.ID).Cols("size").Update(repo); err != nil {
|
if _, err = x.ID(repo.ID).Cols("size").Update(repo); err != nil {
|
||||||
return fmt.Errorf("update size: %v", err)
|
return fmt.Errorf("update size: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ func removeCommitsUnitType(x *xorm.Engine) (err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
team.UnitTypes = ut
|
team.UnitTypes = ut
|
||||||
if _, err := x.Id(team.ID).Cols("unit_types").Update(team); err != nil {
|
if _, err := x.ID(team.ID).Cols("unit_types").Update(team); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ func addTimetracking(x *xorm.Engine) error {
|
||||||
changes = true
|
changes = true
|
||||||
}
|
}
|
||||||
if changes {
|
if changes {
|
||||||
if _, err := x.Id(unit.ID).Cols("config").Update(unit); err != nil {
|
if _, err := x.ID(unit.ID).Cols("config").Update(unit); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ type Engine interface {
|
||||||
Exec(string, ...interface{}) (sql.Result, error)
|
Exec(string, ...interface{}) (sql.Result, error)
|
||||||
Find(interface{}, ...interface{}) error
|
Find(interface{}, ...interface{}) error
|
||||||
Get(interface{}) (bool, error)
|
Get(interface{}) (bool, error)
|
||||||
Id(interface{}) *xorm.Session
|
ID(interface{}) *xorm.Session
|
||||||
In(string, ...interface{}) *xorm.Session
|
In(string, ...interface{}) *xorm.Session
|
||||||
Incr(column string, arg ...interface{}) *xorm.Session
|
Incr(column string, arg ...interface{}) *xorm.Session
|
||||||
Insert(...interface{}) (int64, error)
|
Insert(...interface{}) (int64, error)
|
||||||
|
|
|
@ -195,7 +195,7 @@ func updateIssueNotification(e Engine, userID, issueID, updatedByID int64) error
|
||||||
notification.Status = NotificationStatusUnread
|
notification.Status = NotificationStatusUnread
|
||||||
notification.UpdatedBy = updatedByID
|
notification.UpdatedBy = updatedByID
|
||||||
|
|
||||||
_, err = e.Id(notification.ID).Update(notification)
|
_, err = e.ID(notification.ID).Update(notification)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ func setNotificationStatusReadIfUnread(e Engine, userID, issueID int64) error {
|
||||||
|
|
||||||
notification.Status = NotificationStatusRead
|
notification.Status = NotificationStatusRead
|
||||||
|
|
||||||
_, err = e.Id(notification.ID).Update(notification)
|
_, err = e.ID(notification.ID).Update(notification)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ func SetNotificationStatus(notificationID int64, user *User, status Notification
|
||||||
|
|
||||||
notification.Status = status
|
notification.Status = status
|
||||||
|
|
||||||
_, err = x.Id(notificationID).Update(notification)
|
_, err = x.ID(notificationID).Update(notification)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -259,7 +259,7 @@ func deleteOrg(e *xorm.Session, u *User) error {
|
||||||
return fmt.Errorf("deleteBeans: %v", err)
|
return fmt.Errorf("deleteBeans: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err = e.Id(u.ID).Delete(new(User)); err != nil {
|
if _, err = e.ID(u.ID).Delete(new(User)); err != nil {
|
||||||
return fmt.Errorf("Delete: %v", err)
|
return fmt.Errorf("Delete: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,7 +412,7 @@ func ChangeOrgUserStatus(orgID, uid int64, public bool) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
ou.IsPublic = public
|
ou.IsPublic = public
|
||||||
_, err = x.Id(ou.ID).Cols("is_public").Update(ou)
|
_, err = x.ID(ou.ID).Cols("is_public").Update(ou)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,7 +480,7 @@ func RemoveOrgUser(orgID, userID int64) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := sess.Id(ou.ID).Delete(ou); err != nil {
|
if _, err := sess.ID(ou.ID).Delete(ou); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if _, err = sess.Exec("UPDATE `user` SET num_members=num_members-1 WHERE id=?", orgID); err != nil {
|
} else if _, err = sess.Exec("UPDATE `user` SET num_members=num_members-1 WHERE id=?", orgID); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -96,7 +96,7 @@ func (t *Team) addRepository(e Engine, repo *Repository) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
t.NumRepos++
|
t.NumRepos++
|
||||||
if _, err = e.Id(t.ID).Cols("num_repos").Update(t); err != nil {
|
if _, err = e.ID(t.ID).Cols("num_repos").Update(t); err != nil {
|
||||||
return fmt.Errorf("update team: %v", err)
|
return fmt.Errorf("update team: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ func (t *Team) removeRepository(e Engine, repo *Repository, recalculate bool) (e
|
||||||
}
|
}
|
||||||
|
|
||||||
t.NumRepos--
|
t.NumRepos--
|
||||||
if _, err = e.Id(t.ID).Cols("num_repos").Update(t); err != nil {
|
if _, err = e.ID(t.ID).Cols("num_repos").Update(t); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ func NewTeam(t *Team) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
has, err := x.Id(t.OrgID).Get(new(User))
|
has, err := x.ID(t.OrgID).Get(new(User))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
|
@ -289,7 +289,7 @@ func GetTeam(orgID int64, name string) (*Team, error) {
|
||||||
|
|
||||||
func getTeamByID(e Engine, teamID int64) (*Team, error) {
|
func getTeamByID(e Engine, teamID int64) (*Team, error) {
|
||||||
t := new(Team)
|
t := new(Team)
|
||||||
has, err := e.Id(teamID).Get(t)
|
has, err := e.ID(teamID).Get(t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
|
@ -331,7 +331,7 @@ func UpdateTeam(t *Team, authChanged bool) (err error) {
|
||||||
return ErrTeamAlreadyExist{t.OrgID, t.LowerName}
|
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)
|
return fmt.Errorf("update: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,7 +387,7 @@ func DeleteTeam(t *Team) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete team.
|
// 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
|
return err
|
||||||
}
|
}
|
||||||
// Update organization number of teams.
|
// Update organization number of teams.
|
||||||
|
@ -498,7 +498,7 @@ func AddTeamMember(team *Team, userID int64) error {
|
||||||
TeamID: team.ID,
|
TeamID: team.ID,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if _, err := sess.Id(team.ID).Update(team); err != nil {
|
} else if _, err := sess.ID(team.ID).Update(team); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,7 +521,7 @@ func AddTeamMember(team *Team, userID int64) error {
|
||||||
if team.IsOwnerTeam() {
|
if team.IsOwnerTeam() {
|
||||||
ou.IsOwner = true
|
ou.IsOwner = true
|
||||||
}
|
}
|
||||||
if _, err := sess.Id(ou.ID).Cols("num_teams, is_owner").Update(ou); err != nil {
|
if _, err := sess.ID(ou.ID).Cols("num_teams, is_owner").Update(ou); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,7 +551,7 @@ func removeTeamMember(e Engine, team *Team, userID int64) error {
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if _, err = e.
|
} else if _, err = e.
|
||||||
Id(team.ID).
|
ID(team.ID).
|
||||||
Cols("num_members").
|
Cols("num_members").
|
||||||
Update(team); err != nil {
|
Update(team); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -578,7 +578,7 @@ func removeTeamMember(e Engine, team *Team, userID int64) error {
|
||||||
ou.IsOwner = false
|
ou.IsOwner = false
|
||||||
}
|
}
|
||||||
if _, err = e.
|
if _, err = e.
|
||||||
Id(ou.ID).
|
ID(ou.ID).
|
||||||
Cols("num_teams").
|
Cols("num_teams").
|
||||||
Update(ou); err != nil {
|
Update(ou); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -422,7 +422,7 @@ func (pr *PullRequest) setMerged() (err error) {
|
||||||
if err = pr.Issue.changeStatus(sess, pr.Merger, pr.Issue.Repo, true); err != nil {
|
if err = pr.Issue.changeStatus(sess, pr.Merger, pr.Issue.Repo, true); err != nil {
|
||||||
return fmt.Errorf("Issue.changeStatus: %v", err)
|
return fmt.Errorf("Issue.changeStatus: %v", err)
|
||||||
}
|
}
|
||||||
if _, err = sess.Id(pr.ID).Cols("has_merged").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)
|
return fmt.Errorf("update pull request: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -795,7 +795,7 @@ func GetPullRequestByIndex(repoID int64, index int64) (*PullRequest, error) {
|
||||||
|
|
||||||
func getPullRequestByID(e Engine, id int64) (*PullRequest, error) {
|
func getPullRequestByID(e Engine, id int64) (*PullRequest, error) {
|
||||||
pr := new(PullRequest)
|
pr := new(PullRequest)
|
||||||
has, err := e.Id(id).Get(pr)
|
has, err := e.ID(id).Get(pr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
|
@ -829,13 +829,13 @@ func GetPullRequestByIssueID(issueID int64) (*PullRequest, error) {
|
||||||
|
|
||||||
// Update updates all fields of pull request.
|
// Update updates all fields of pull request.
|
||||||
func (pr *PullRequest) Update() error {
|
func (pr *PullRequest) Update() error {
|
||||||
_, err := x.Id(pr.ID).AllCols().Update(pr)
|
_, err := x.ID(pr.ID).AllCols().Update(pr)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateCols updates specific fields of pull request.
|
// UpdateCols updates specific fields of pull request.
|
||||||
func (pr *PullRequest) UpdateCols(cols ...string) error {
|
func (pr *PullRequest) UpdateCols(cols ...string) error {
|
||||||
_, err := x.Id(pr.ID).Cols(cols...).Update(pr)
|
_, err := x.ID(pr.ID).Cols(cols...).Update(pr)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,7 @@ func addReleaseAttachments(releaseID int64, attachmentUUIDs []string) (err error
|
||||||
for i := range attachments {
|
for i := range attachments {
|
||||||
attachments[i].ReleaseID = releaseID
|
attachments[i].ReleaseID = releaseID
|
||||||
// No assign value could be 0, so ignore AllCols().
|
// No assign value could be 0, so ignore AllCols().
|
||||||
if _, err = x.Id(attachments[i].ID).Update(attachments[i]); err != nil {
|
if _, err = x.ID(attachments[i].ID).Update(attachments[i]); err != nil {
|
||||||
return fmt.Errorf("update attachment [%d]: %v", attachments[i].ID, err)
|
return fmt.Errorf("update attachment [%d]: %v", attachments[i].ID, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ func GetRelease(repoID int64, tagName string) (*Release, error) {
|
||||||
func GetReleaseByID(id int64) (*Release, error) {
|
func GetReleaseByID(id int64) (*Release, error) {
|
||||||
rel := new(Release)
|
rel := new(Release)
|
||||||
has, err := x.
|
has, err := x.
|
||||||
Id(id).
|
ID(id).
|
||||||
Get(rel)
|
Get(rel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -365,7 +365,7 @@ func UpdateRelease(gitRepo *git.Repository, rel *Release, attachmentUUIDs []stri
|
||||||
}
|
}
|
||||||
rel.LowerTagName = strings.ToLower(rel.TagName)
|
rel.LowerTagName = strings.ToLower(rel.TagName)
|
||||||
|
|
||||||
_, err = x.Id(rel.ID).AllCols().Update(rel)
|
_, err = x.ID(rel.ID).AllCols().Update(rel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -402,7 +402,7 @@ func DeleteReleaseByID(id int64, u *User, delTag bool) error {
|
||||||
return fmt.Errorf("git tag -d: %v - %s", err, stderr)
|
return fmt.Errorf("git tag -d: %v - %s", err, stderr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err = x.Id(rel.ID).Delete(new(Release)); err != nil {
|
if _, err = x.ID(rel.ID).Delete(new(Release)); err != nil {
|
||||||
return fmt.Errorf("Delete: %v", err)
|
return fmt.Errorf("Delete: %v", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -412,7 +412,7 @@ func DeleteReleaseByID(id int64, u *User, delTag bool) error {
|
||||||
rel.Title = ""
|
rel.Title = ""
|
||||||
rel.Note = ""
|
rel.Note = ""
|
||||||
|
|
||||||
if _, err = x.Id(rel.ID).AllCols().Update(rel); err != nil {
|
if _, err = x.ID(rel.ID).AllCols().Update(rel); err != nil {
|
||||||
return fmt.Errorf("Update: %v", err)
|
return fmt.Errorf("Update: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -620,7 +620,7 @@ func (repo *Repository) updateSize(e Engine) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
repo.Size = repoInfoSize.Size + repoInfoSize.SizePack
|
repo.Size = repoInfoSize.Size + repoInfoSize.SizePack
|
||||||
_, err = e.Id(repo.ID).Cols("size").Update(repo)
|
_, err = e.ID(repo.ID).Cols("size").Update(repo)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1417,7 +1417,7 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error
|
||||||
repo.Owner = newOwner
|
repo.Owner = newOwner
|
||||||
|
|
||||||
// Update repository.
|
// 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)
|
return fmt.Errorf("update owner: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1449,7 +1449,7 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error
|
||||||
}
|
}
|
||||||
|
|
||||||
t.NumRepos--
|
t.NumRepos--
|
||||||
if _, err := sess.Id(t.ID).Cols("num_repos").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)
|
return fmt.Errorf("decrease team repository count '%d': %v", t.ID, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1568,7 +1568,7 @@ func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err e
|
||||||
repo.Website = repo.Website[:255]
|
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)
|
return fmt.Errorf("update: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1687,7 +1687,7 @@ func DeleteRepository(doer *User, uid, repoID int64) error {
|
||||||
return ErrRepoNotExist{repoID, uid, ""}
|
return ErrRepoNotExist{repoID, uid, ""}
|
||||||
}
|
}
|
||||||
|
|
||||||
if cnt, err := sess.Id(repoID).Delete(&Repository{}); err != nil {
|
if cnt, err := sess.ID(repoID).Delete(&Repository{}); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if cnt != 1 {
|
} else if cnt != 1 {
|
||||||
return ErrRepoNotExist{repoID, uid, ""}
|
return ErrRepoNotExist{repoID, uid, ""}
|
||||||
|
@ -1868,7 +1868,7 @@ func GetRepositoryByName(ownerID int64, name string) (*Repository, error) {
|
||||||
|
|
||||||
func getRepositoryByID(e Engine, id int64) (*Repository, error) {
|
func getRepositoryByID(e Engine, id int64) (*Repository, error) {
|
||||||
repo := new(Repository)
|
repo := new(Repository)
|
||||||
has, err := e.Id(id).Get(repo)
|
has, err := e.ID(id).Get(repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
|
|
|
@ -199,7 +199,7 @@ func GetMirrorByRepoID(repoID int64) (*Mirror, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateMirror(e Engine, m *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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -722,7 +722,7 @@ func AddDeployKey(repoID int64, name, content string) (*DeployKey, error) {
|
||||||
// GetDeployKeyByID returns deploy key by given ID.
|
// GetDeployKeyByID returns deploy key by given ID.
|
||||||
func GetDeployKeyByID(id int64) (*DeployKey, error) {
|
func GetDeployKeyByID(id int64) (*DeployKey, error) {
|
||||||
key := new(DeployKey)
|
key := new(DeployKey)
|
||||||
has, err := x.Id(id).Get(key)
|
has, err := x.ID(id).Get(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
|
@ -748,7 +748,7 @@ func GetDeployKeyByRepo(keyID, repoID int64) (*DeployKey, error) {
|
||||||
|
|
||||||
// UpdateDeployKey updates deploy key information.
|
// UpdateDeployKey updates deploy key information.
|
||||||
func UpdateDeployKey(key *DeployKey) error {
|
func UpdateDeployKey(key *DeployKey) error {
|
||||||
_, err := x.Id(key.ID).AllCols().Update(key)
|
_, err := x.ID(key.ID).AllCols().Update(key)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -782,7 +782,7 @@ func DeleteDeployKey(doer *User, id int64) error {
|
||||||
return err
|
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)
|
return fmt.Errorf("delete deploy key [%d]: %v", key.ID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,13 +68,13 @@ func ListAccessTokens(uid int64) ([]*AccessToken, error) {
|
||||||
|
|
||||||
// UpdateAccessToken updates information of access token.
|
// UpdateAccessToken updates information of access token.
|
||||||
func UpdateAccessToken(t *AccessToken) error {
|
func UpdateAccessToken(t *AccessToken) error {
|
||||||
_, err := x.Id(t.ID).AllCols().Update(t)
|
_, err := x.ID(t.ID).AllCols().Update(t)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteAccessTokenByID deletes access token by given ID.
|
// DeleteAccessTokenByID deletes access token by given ID.
|
||||||
func DeleteAccessTokenByID(id, userID int64) error {
|
func DeleteAccessTokenByID(id, userID int64) error {
|
||||||
cnt, err := x.Id(id).Delete(&AccessToken{
|
cnt, err := x.ID(id).Delete(&AccessToken{
|
||||||
UID: userID,
|
UID: userID,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -95,7 +95,7 @@ func NewTwoFactor(t *TwoFactor) error {
|
||||||
|
|
||||||
// UpdateTwoFactor updates a two-factor authentication token.
|
// UpdateTwoFactor updates a two-factor authentication token.
|
||||||
func UpdateTwoFactor(t *TwoFactor) error {
|
func UpdateTwoFactor(t *TwoFactor) error {
|
||||||
_, err := x.Id(t.ID).AllCols().Update(t)
|
_, err := x.ID(t.ID).AllCols().Update(t)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ func GetTwoFactorByUID(uid int64) (*TwoFactor, error) {
|
||||||
|
|
||||||
// DeleteTwoFactorByID deletes two-factor authentication token by given ID.
|
// DeleteTwoFactorByID deletes two-factor authentication token by given ID.
|
||||||
func DeleteTwoFactorByID(id, userID int64) error {
|
func DeleteTwoFactorByID(id, userID int64) error {
|
||||||
cnt, err := x.Id(id).Delete(&TwoFactor{
|
cnt, err := x.ID(id).Delete(&TwoFactor{
|
||||||
UID: userID,
|
UID: userID,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -90,14 +90,14 @@ func pushUpdateDeleteTag(repo *Repository, gitRepo *git.Repository, tagName stri
|
||||||
return fmt.Errorf("GetRelease: %v", err)
|
return fmt.Errorf("GetRelease: %v", err)
|
||||||
}
|
}
|
||||||
if rel.IsTag {
|
if rel.IsTag {
|
||||||
if _, err = x.Id(rel.ID).Delete(new(Release)); err != nil {
|
if _, err = x.ID(rel.ID).Delete(new(Release)); err != nil {
|
||||||
return fmt.Errorf("Delete: %v", err)
|
return fmt.Errorf("Delete: %v", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rel.IsDraft = true
|
rel.IsDraft = true
|
||||||
rel.NumCommits = 0
|
rel.NumCommits = 0
|
||||||
rel.Sha1 = ""
|
rel.Sha1 = ""
|
||||||
if _, err = x.Id(rel.ID).AllCols().Update(rel); err != nil {
|
if _, err = x.ID(rel.ID).AllCols().Update(rel); err != nil {
|
||||||
return fmt.Errorf("Update: %v", err)
|
return fmt.Errorf("Update: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ func pushUpdateAddTag(repo *Repository, gitRepo *git.Repository, tagName string)
|
||||||
if rel.IsTag && author != nil {
|
if rel.IsTag && author != nil {
|
||||||
rel.PublisherID = author.ID
|
rel.PublisherID = author.ID
|
||||||
}
|
}
|
||||||
if _, err = x.Id(rel.ID).AllCols().Update(rel); err != nil {
|
if _, err = x.ID(rel.ID).AllCols().Update(rel); err != nil {
|
||||||
return fmt.Errorf("Update: %v", err)
|
return fmt.Errorf("Update: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -302,7 +302,7 @@ func (u *User) generateRandomAvatar(e Engine) error {
|
||||||
}
|
}
|
||||||
defer fw.Close()
|
defer fw.Close()
|
||||||
|
|
||||||
if _, err := e.Id(u.ID).Cols("avatar").Update(u); err != nil {
|
if _, err := e.ID(u.ID).Cols("avatar").Update(u); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,7 +459,7 @@ func (u *User) DeleteAvatar() error {
|
||||||
|
|
||||||
u.UseCustomAvatar = false
|
u.UseCustomAvatar = false
|
||||||
u.Avatar = ""
|
u.Avatar = ""
|
||||||
if _, err := x.Id(u.ID).Cols("avatar, use_custom_avatar").Update(u); err != nil {
|
if _, err := x.ID(u.ID).Cols("avatar, use_custom_avatar").Update(u); err != nil {
|
||||||
return fmt.Errorf("UpdateUser: %v", err)
|
return fmt.Errorf("UpdateUser: %v", err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -862,7 +862,7 @@ func updateUser(e Engine, u *User) error {
|
||||||
u.Website = base.TruncateString(u.Website, 255)
|
u.Website = base.TruncateString(u.Website, 255)
|
||||||
u.Description = base.TruncateString(u.Description, 255)
|
u.Description = base.TruncateString(u.Description, 255)
|
||||||
|
|
||||||
_, err := e.Id(u.ID).AllCols().Update(u)
|
_, err := e.ID(u.ID).AllCols().Update(u)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -893,7 +893,7 @@ func updateUserCols(e Engine, u *User, cols ...string) error {
|
||||||
u.Website = base.TruncateString(u.Website, 255)
|
u.Website = base.TruncateString(u.Website, 255)
|
||||||
u.Description = base.TruncateString(u.Description, 255)
|
u.Description = base.TruncateString(u.Description, 255)
|
||||||
|
|
||||||
_, err := e.Id(u.ID).Cols(cols...).Update(u)
|
_, err := e.ID(u.ID).Cols(cols...).Update(u)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1019,7 +1019,7 @@ func deleteUser(e *xorm.Session, u *User) error {
|
||||||
}
|
}
|
||||||
// ***** END: ExternalLoginUser *****
|
// ***** END: ExternalLoginUser *****
|
||||||
|
|
||||||
if _, err = e.Id(u.ID).Delete(new(User)); err != nil {
|
if _, err = e.ID(u.ID).Delete(new(User)); err != nil {
|
||||||
return fmt.Errorf("Delete: %v", err)
|
return fmt.Errorf("Delete: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1112,7 +1112,7 @@ func GetUserByKeyID(keyID int64) (*User, error) {
|
||||||
|
|
||||||
func getUserByID(e Engine, id int64) (*User, error) {
|
func getUserByID(e Engine, id int64) (*User, error) {
|
||||||
u := new(User)
|
u := new(User)
|
||||||
has, err := e.Id(id).Get(u)
|
has, err := e.ID(id).Get(u)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
|
|
|
@ -153,7 +153,7 @@ func DeleteEmailAddress(email *EmailAddress) (err error) {
|
||||||
UID: email.UID,
|
UID: email.UID,
|
||||||
}
|
}
|
||||||
if email.ID > 0 {
|
if email.ID > 0 {
|
||||||
deleted, err = x.Id(email.ID).Delete(&address)
|
deleted, err = x.ID(email.ID).Delete(&address)
|
||||||
} else {
|
} else {
|
||||||
deleted, err = x.
|
deleted, err = x.
|
||||||
Where("email=?", email.Email).
|
Where("email=?", email.Email).
|
||||||
|
@ -222,7 +222,7 @@ func MakeEmailPrimary(email *EmailAddress) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
user.Email = email.Email
|
user.Email = email.Email
|
||||||
if _, err = sess.Id(user.ID).Cols("email").Update(user); err != nil {
|
if _, err = sess.ID(user.ID).Cols("email").Update(user); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ func DeleteUserOpenID(openid *UserOpenID) (err error) {
|
||||||
UID: openid.UID,
|
UID: openid.UID,
|
||||||
}
|
}
|
||||||
if openid.ID > 0 {
|
if openid.ID > 0 {
|
||||||
deleted, err = x.Id(openid.ID).Delete(&address)
|
deleted, err = x.ID(openid.ID).Delete(&address)
|
||||||
} else {
|
} else {
|
||||||
deleted, err = x.
|
deleted, err = x.
|
||||||
Where("openid=?", openid.URI).
|
Where("openid=?", openid.URI).
|
||||||
|
|
|
@ -270,7 +270,7 @@ func GetWebhooksByOrgID(orgID int64) (ws []*Webhook, err error) {
|
||||||
|
|
||||||
// UpdateWebhook updates information of webhook.
|
// UpdateWebhook updates information of webhook.
|
||||||
func UpdateWebhook(w *Webhook) error {
|
func UpdateWebhook(w *Webhook) error {
|
||||||
_, err := x.Id(w.ID).AllCols().Update(w)
|
_, err := x.ID(w.ID).AllCols().Update(w)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,7 +477,7 @@ func createHookTask(e Engine, t *HookTask) error {
|
||||||
|
|
||||||
// UpdateHookTask updates information of hook task.
|
// UpdateHookTask updates information of hook task.
|
||||||
func UpdateHookTask(t *HookTask) error {
|
func UpdateHookTask(t *HookTask) error {
|
||||||
_, err := x.Id(t.ID).AllCols().Update(t)
|
_, err := x.ID(t.ID).AllCols().Update(t)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue