are `upsert` and `connectOrCreate` somehow incompa...
# orm-help
b
are
upsert
and
connectOrCreate
somehow incompatible? 🤔 i've got something along the lines of:
Copy code
const director = someBoolean ? { connectOrCreate: { create: { name: 'Steven Spielberg' }, where: { name: 'Steven Spielberg' }  } } : undefined
const movie = { contentId: 'some_id_here', title: 'Jaws', director }

const upsertResult = await prisma.movie.upsert({ create: movie, update: movie, where: { contentId: movie.contentId } })
// results in "The change you are trying to make would violate the required relation 'DirectorToMovie' between the 'Director' and 'Movie' models.
for reference, the Movie model lists a director as being optional, which is why I'm so confused at it complaining that it would break a required relation. Not sure if it's important, but I'm using sqlite as the underlying db
Copy code
model Movie {
  id        Int @id @default(autoincrement())
  contentId String
  title     String
  director  Director?
}

model Director {
  id      Int @id @default(autoincrement())
  name    String @unique
  movie   Movie @relation(fields: [movieId], references: [id])
  movieId Int
}
r
The
Movie
lists that as optional, but the
movie
is required in
Director
. Could you try making that optional and then check?