Fix possible sorting overflow

This commit is contained in:
Lunny Xiao 2024-04-30 15:44:49 +08:00
parent 3710ea2e5e
commit e3d553157a
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A

View File

@ -171,7 +171,14 @@ func NewBoard(ctx context.Context, board *Board) error {
}
if totalColumns > 0 {
board.Sorting = int8(totalColumns)
var maxSorting int8
if _, err := db.GetEngine(ctx).Select("Max(sorting)").Table("project_board").
Where("project_id=?", board.ProjectID).Get(&maxSorting); err != nil {
return err
}
if maxSorting > 0 {
board.Sorting = maxSorting + 1
}
}
_, err = db.GetEngine(ctx).Insert(board)