prisma: @@unique block attribute fails for non-scalar types (regression)

Based on the following snippet from the PSL spec, @@unique should work fine for non-scalar types:

@@unique([recipe, ingredient]) would mean that the combination of fields must be unique in the table:

model RecipeIngredient {
  recipe                            Recipe
  ingredient                      Ingredient
  amount                          Float
  quantitativeDisclosures String
  comment                       String
  @@unique([recipe, ingredient])
}

The semantic meaning seems intuitive here and implies a comparison based on the @id field of the Recipe and Ingredient objects. As of 2.0.0-preview017.2, this was working but some time after that point started failing with a panic as described in #1352. #1352 was closed in favor of #1377, but @janpio mentioned #1377 covers improving the error message but not the regression.

I know nothing about Rust, but https://github.com/prisma/prisma-engine/pull/241 looks like a likely root cause to me. The timing is about right and it seems like all of the tests expect that fields passed to @@unique are scalar.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (9 by maintainers)

Most upvoted comments

Week has gone, I did not get to update the issues yet. Work is still ongoing on the problem itself but we are making progress.