HF RL Explorer

Task: Create a Unique Constraint That Treats NULL as Equal in PostgreSQL

Task: Create a Unique Constraint That Treats NULL as Equal in PostgreSQL: a task in Terminal-Lego-15k (Harbor dataset). Create a PostgreSQL solution that enforces a unique constraint on a Favorites table where the combination of (UserId, MenuId, RecipeId) is unique, but also prevents duplicate…

The task

Create a PostgreSQL solution that enforces a unique constraint on a `Favorites` table where the combination of `(UserId, MenuId, RecipeId)` is unique, but also prevents duplicate `(UserId, RecipeId)` pairs when `MenuId IS NULL`. Standard unique constraints treat NULLs as distinct, so you need to implement a workaround.

Part of PrimeIntellect/Terminal-Lego-15k.