From 4d729b0969fbc99a25b251f49c97e978052dd3fe Mon Sep 17 00:00:00 2001 From: Nodude <75137537+NodudeWasTaken@users.noreply.github.com> Date: Thu, 7 Nov 2024 10:42:02 +0100 Subject: [PATCH] Fix bug in tags that made finding ancestors and descendants not work in postgresql. Postgres is stricter and doesnt allow excess args. --- pkg/sqlite/tag.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pkg/sqlite/tag.go b/pkg/sqlite/tag.go index 361486a7ae4..c2c5c8d5b71 100644 --- a/pkg/sqlite/tag.go +++ b/pkg/sqlite/tag.go @@ -907,12 +907,10 @@ parents AS ( SELECT t.*, p.path FROM tags t INNER JOIN parents p ON t.id = p.parent_id ` - excludeArgs := []interface{}{tagID} + args := []interface{}{tagID, tagID} for _, excludeID := range excludeIDs { - excludeArgs = append(excludeArgs, excludeID) + args = append(args, excludeID) } - args := []interface{}{tagID} - args = append(args, append(append(excludeArgs, excludeArgs...), excludeArgs...)...) return qb.queryTagPaths(ctx, query, args) } @@ -931,12 +929,10 @@ children AS ( SELECT t.*, c.path FROM tags t INNER JOIN children c ON t.id = c.child_id ` - excludeArgs := []interface{}{tagID} + args := []interface{}{tagID, tagID} for _, excludeID := range excludeIDs { - excludeArgs = append(excludeArgs, excludeID) + args = append(args, excludeID) } - args := []interface{}{tagID} - args = append(args, append(append(excludeArgs, excludeArgs...), excludeArgs...)...) return qb.queryTagPaths(ctx, query, args) }