Skip to content

Commit 77f6de7

Browse files
Crnaneoppolariss
authored andcommitted
fix: char length err in mysql
1 parent faf8586 commit 77f6de7

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

models/hole.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,12 @@ func (holes Holes) Preprocess(c *fiber.Ctx) error {
289289
var contentSum int64
290290
var sensitiveCount int64
291291

292-
err := query.Select("COALESCE(SUM(LENGTH(content)), 0)").Scan(&contentSum).Error
292+
contentSumQuery := "SUM(CHAR_LENGTH(content))"
293+
if DB.Dialector.Name() == "sqlite" {
294+
contentSumQuery = "SUM(LENGTH(content))"
295+
}
296+
297+
err := query.Select(fmt.Sprintf("COALESCE(%s, 0)", contentSumQuery)).Scan(&contentSum).Error
293298
if err != nil {
294299
return err
295300
}

0 commit comments

Comments
 (0)