From 564947e75cb8e5239e467ea99cb8e5444f044fdf Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Tue, 19 Apr 2022 02:50:31 +0300 Subject: [PATCH] Make assigning new article number bound to a group --- internal/backend/sqlite/sqlite.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/backend/sqlite/sqlite.go b/internal/backend/sqlite/sqlite.go index 7d2da00..2242558 100644 --- a/internal/backend/sqlite/sqlite.go +++ b/internal/backend/sqlite/sqlite.go @@ -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 }