Make assigning new article number bound to a group

This commit is contained in:
ChronosX88 2022-04-19 02:50:31 +03:00
parent 7d5d277a1f
commit 564947e75c
Signed by: ChronosXYZ
GPG Key ID: 085A69A82C8C511A

View File

@ -119,7 +119,7 @@ func (sb *SQLiteBackend) SaveArticle(a models.Article, groups []string) error {
}
for _, v := range groupIDs {
_, err = sb.db.Exec("INSERT INTO articles_to_groups (article_id, article_number, group_id) VALUES (?, (SELECT ifnull(max(article_number)+1, 1) FROM articles_to_groups), ?)", articleID, v)
_, err = sb.db.Exec("INSERT INTO articles_to_groups (article_id, article_number, group_id) VALUES (?, (SELECT ifnull(max(article_number)+1, 1) FROM articles_to_groups WHERE group_id = ?), ?)", articleID, v, v)
if err != nil {
return err
}