1
0

fix: reset id before creating

(cherry picked from commit c252c8f0cd1c09a74b564e67a855cca4cd436585)
This commit is contained in:
kolaente 2024-09-17 10:46:14 +02:00
parent 0e683ae7bf
commit 93f7dd611a
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
14 changed files with 18 additions and 4 deletions

View File

@ -306,6 +306,7 @@ func (b *Bucket) Create(s *xorm.Session, a web.Auth) (err error) {
} }
b.CreatedByID = b.CreatedBy.ID b.CreatedByID = b.CreatedBy.ID
b.ID = 0
_, err = s.Insert(b) _, err = s.Insert(b)
if err != nil { if err != nil {
return return

View File

@ -97,7 +97,7 @@ func (lt *LabelTask) Create(s *xorm.Session, auth web.Auth) (err error) {
return ErrLabelIsAlreadyOnTask{lt.LabelID, lt.TaskID} return ErrLabelIsAlreadyOnTask{lt.LabelID, lt.TaskID}
} }
// Insert it lt.ID = 0
_, err = s.Insert(lt) _, err = s.Insert(lt)
if err != nil { if err != nil {
return err return err
@ -386,7 +386,10 @@ func (t *Task) UpdateTaskLabels(s *xorm.Session, creator web.Auth, labels []*Lab
} }
// Insert it // Insert it
_, err = s.Insert(&LabelTask{LabelID: l.ID, TaskID: t.ID}) _, err = s.Insert(&LabelTask{
LabelID: l.ID,
TaskID: t.ID,
})
if err != nil { if err != nil {
return err return err
} }

View File

@ -154,6 +154,7 @@ func (share *LinkSharing) Create(s *xorm.Session, a web.Auth) (err error) {
share.SharingType = SharingTypeWithoutPassword share.SharingType = SharingTypeWithoutPassword
} }
share.ID = 0
_, err = s.Insert(share) _, err = s.Insert(share)
share.Password = "" share.Password = ""
share.SharedBy, _ = user.GetFromAuth(a) share.SharedBy, _ = user.GetFromAuth(a)

View File

@ -104,6 +104,7 @@ func (tl *TeamProject) Create(s *xorm.Session, a web.Auth) (err error) {
} }
// Insert the new team // Insert the new team
tl.ID = 0
_, err = s.Insert(tl) _, err = s.Insert(tl)
if err != nil { if err != nil {
return err return err

View File

@ -110,7 +110,7 @@ func (lu *ProjectUser) Create(s *xorm.Session, a web.Auth) (err error) {
return ErrUserAlreadyHasAccess{UserID: lu.UserID, ProjectID: lu.ProjectID} return ErrUserAlreadyHasAccess{UserID: lu.UserID, ProjectID: lu.ProjectID}
} }
// Insert user <-> project relation lu.ID = 0
_, err = s.Insert(lu) _, err = s.Insert(lu)
if err != nil { if err != nil {
return err return err

View File

@ -263,6 +263,7 @@ func (pv *ProjectView) Create(s *xorm.Session, a web.Auth) (err error) {
} }
func createProjectView(s *xorm.Session, p *ProjectView, a web.Auth, createBacklogBucket bool, addExistingTasksToView bool) (err error) { func createProjectView(s *xorm.Session, p *ProjectView, a web.Auth, createBacklogBucket bool, addExistingTasksToView bool) (err error) {
p.ID = 0
_, err = s.Insert(p) _, err = s.Insert(p)
if err != nil { if err != nil {
return return

View File

@ -186,6 +186,7 @@ func (r *Reaction) Create(s *xorm.Session, a web.Auth) (err error) {
return return
} }
r.ID = 0
_, err = s.Insert(r) _, err = s.Insert(r)
return return
} }

View File

@ -121,6 +121,7 @@ func (sf *SavedFilter) toProject() *Project {
// @Router /filters [put] // @Router /filters [put]
func (sf *SavedFilter) Create(s *xorm.Session, auth web.Auth) (err error) { func (sf *SavedFilter) Create(s *xorm.Session, auth web.Auth) (err error) {
sf.OwnerID = auth.GetID() sf.OwnerID = auth.GetID()
sf.ID = 0
_, err = s.Insert(sf) _, err = s.Insert(sf)
if err != nil { if err != nil {
return return

View File

@ -147,6 +147,7 @@ func (sb *Subscription) TableName() string {
func (sb *Subscription) Create(s *xorm.Session, auth web.Auth) (err error) { func (sb *Subscription) Create(s *xorm.Session, auth web.Auth) (err error) {
// Rights method already does the validation of the entity type, so we don't need to do that here // Rights method already does the validation of the entity type, so we don't need to do that here
sb.ID = 0
sb.UserID = auth.GetID() sb.UserID = auth.GetID()
sub, err := GetSubscriptionForUser(s, sb.EntityType, sb.EntityID, auth) sub, err := GetSubscriptionForUser(s, sb.EntityType, sb.EntityID, auth)

View File

@ -66,6 +66,7 @@ func (tc *TaskComment) TableName() string {
// @Router /tasks/{taskID}/comments [put] // @Router /tasks/{taskID}/comments [put]
func (tc *TaskComment) Create(s *xorm.Session, a web.Auth) (err error) { func (tc *TaskComment) Create(s *xorm.Session, a web.Auth) (err error) {
tc.ID = 0
tc.Created = time.Time{} tc.Created = time.Time{}
tc.Updated = time.Time{} tc.Updated = time.Time{}

View File

@ -230,6 +230,7 @@ func (rel *TaskRelation) Create(s *xorm.Session, a web.Auth) error {
return err return err
} }
rel.CreatedByID = rel.CreatedBy.ID rel.CreatedByID = rel.CreatedBy.ID
rel.ID = 0
// Build up the other relation (see the comment above for explanation) // Build up the other relation (see the comment above for explanation)
otherRelation := &TaskRelation{ otherRelation := &TaskRelation{

View File

@ -62,7 +62,7 @@ func (tm *TeamMember) Create(s *xorm.Session, a web.Auth) (err error) {
return ErrUserIsMemberOfTeam{tm.TeamID, tm.UserID} return ErrUserIsMemberOfTeam{tm.TeamID, tm.UserID}
} }
// Insert the user tm.ID = 0
_, err = s.Insert(tm) _, err = s.Insert(tm)
if err != nil { if err != nil {
return err return err

View File

@ -236,6 +236,7 @@ func (t *Team) CreateNewTeam(s *xorm.Session, a web.Auth, firstUserShouldBeAdmin
return ErrTeamNameCannotBeEmpty{} return ErrTeamNameCannotBeEmpty{}
} }
t.ID = 0
t.CreatedByID = doer.ID t.CreatedByID = doer.ID
t.CreatedBy = doer t.CreatedBy = doer

View File

@ -127,6 +127,7 @@ func (w *Webhook) Create(s *xorm.Session, a web.Auth) (err error) {
} }
w.CreatedByID = a.GetID() w.CreatedByID = a.GetID()
w.ID = 0
_, err = s.Insert(w) _, err = s.Insert(w)
if err != nil { if err != nil {
return err return err