Skip to content

Commit

Permalink
fix: Safely unpack the array of achieved tiers in SQL (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinszuchet authored Sep 9, 2024
1 parent 9dae5da commit 5c73ee6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion common/src/adapters/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ export function createDbComponent({ pg }: Pick<DbComponents, 'pg'>): DbComponent
tier AS achieved_tiers,
updated_at
FROM user_progress,
jsonb_array_elements(achieved_tiers) AS tier
LATERAL jsonb_array_elements(achieved_tiers) AS tier
WHERE user_address = ${userAddress.toLocaleLowerCase()}
AND achieved_tiers IS NOT NULL
AND jsonb_typeof(achieved_tiers) = 'array'
)
SELECT
badge_id,
Expand Down

0 comments on commit 5c73ee6

Please sign in to comment.