Skip to content

Commit

Permalink
use mysql GREATEST to prevent error
Browse files Browse the repository at this point in the history
  • Loading branch information
jibon57 committed Sep 27, 2024
1 parent 22c46be commit 4aac6be
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/services/db/room_modify.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (s *DatabaseService) UpdateNumParticipants(sId string, num int64) (int64, e
// IncrementOrDecrementNumParticipants will increment or decrement the number of Participants
func (s *DatabaseService) IncrementOrDecrementNumParticipants(sId, operator string) (int64, error) {
update := map[string]interface{}{
"joined_participants": gorm.Expr("joined_participants " + operator + "1"),
"joined_participants": gorm.Expr("GREATEST(CAST(joined_participants AS SIGNED)" + operator + " 1, 0)"),
}

result := s.db.Model(&dbmodels.RoomInfo{}).Where("sid = ?", sId).Updates(update)
Expand Down

0 comments on commit 4aac6be

Please sign in to comment.