Skip to content

Commit

Permalink
Fix bug in tags that made finding ancestors and descendants not work …
Browse files Browse the repository at this point in the history
…in postgresql.

Postgres is stricter and doesnt allow excess args.
  • Loading branch information
NodudeWasTaken committed Nov 7, 2024
1 parent 192f757 commit 4d729b0
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions pkg/sqlite/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down

0 comments on commit 4d729b0

Please sign in to comment.