Commit 1016ef75 by JustSong

fix: fix gorm expression

Co-authored-by: 初音控灬 <xyfacai@gmail.com>
parent 489eeff4
...@@ -19,9 +19,9 @@ func GetRandomSatisfiedChannel(group string, model string) (*Channel, error) { ...@@ -19,9 +19,9 @@ func GetRandomSatisfiedChannel(group string, model string) (*Channel, error) {
maxPrioritySubQuery := DB.Model(&Ability{}).Select("MAX(priority)").Where("`group` = ? and model = ? and enabled = 1", group, model) maxPrioritySubQuery := DB.Model(&Ability{}).Select("MAX(priority)").Where("`group` = ? and model = ? and enabled = 1", group, model)
channelQuery := DB.Where("`group` = ? and model = ? and enabled = 1 and priority = (?)", group, model, maxPrioritySubQuery) channelQuery := DB.Where("`group` = ? and model = ? and enabled = 1 and priority = (?)", group, model, maxPrioritySubQuery)
if common.UsingSQLite { if common.UsingSQLite {
err = channelQuery.Order("RANDOM()").Limit(1).First(&ability).Error err = channelQuery.Order("RANDOM()").First(&ability).Error
} else { } else {
err = channelQuery.Order("RAND()").Limit(1).First(&ability).Error err = channelQuery.Order("RAND()").First(&ability).Error
} }
if err != nil { if err != nil {
return nil, err return nil, err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment