Prisma: [Beta1]Optional value with foreign key failed to create

Created on 8 Apr 2020  路  3Comments  路  Source: prisma/prisma

Env:
Beta1, Win10 WSL2, Mysql

image
VSCode Hints:
Error validating: The relation field user uses the scalar fields userId. The arity of those fields must be the same. The relation field is optional but the scalar fields are required.

Removing the "?" everything just fine.

kinquestion arity

All 3 comments

Add a ? to the userId, if ou want an optional relation your column in SQL also needs to be nullable ;)

Yes, the relational scalar userId also needs to be nullable as pointed out by @Sytten.

Try installing beta.2, that should give you a proper validation error for this.

@Sytten @pantharshit00 Thanks a lot!

Was this page helpful?
0 / 5 - 0 ratings