You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{
id: 1,
user_id: null,
user: null
... other fields as expected, like created and updated
}
The above object is what the last two logs print when trying to get the ticket. the connection isn't made in prismock, only when connecting to our database.
I did some digging around in the source code. When connecting, the user_id is passed as null to connectOrCreate in prismock.
I found a way to get the user_id on the item itself without having to directly pass it in the create object
for (const relation of field!.relationFromFields!) {
accumulator[relation] = connect[relation]
}
but even when that value is on item, the logic for finding the user didn't seem to be working. It seems to be hitting this block in create.ts
connected is always null. Connect is passed to where as expected with the user_id. Further debugging showed that checking the User delegate (using .getItems()) returned no items, even though in my test code it returns the users I created. This is about as far as I got.
Relevant models:
model User {
user_id Int @id @default(autoincrement())
tickets Ticket[]
tickets_gifted_by Ticket[] @relation("gifted_by_user")
tickets_gifted_to Ticket[] @relation("gifted_to_user")
....
}
model Ticket {
id Int @id @default(autoincrement())
type TicketType
gifted_to Int?
gifted_to_user User? @relation(name: "gifted_to_user", fields: [gifted_to], references: [user_id])
user_id Int
user User @relation(fields: [user_id], references: [user_id])
...
}
The text was updated successfully, but these errors were encountered:
Thanks for the great package. I'm mocking out tests for our next app, but I am unable to connect on create with this setup.
I create a user earlier in the test and it seems to work fine. I am able to see the user in the first log below.
The above object is what the last two logs print when trying to get the ticket. the connection isn't made in prismock, only when connecting to our database.
I did some digging around in the source code. When connecting, the user_id is passed as null to connectOrCreate in prismock.
I found a way to get the user_id on the item itself without having to directly pass it in the create object
but even when that value is on item, the logic for finding the user didn't seem to be working. It seems to be hitting this block in create.ts
connected is always null. Connect is passed to where as expected with the user_id. Further debugging showed that checking the User delegate (using
.getItems()
) returned no items, even though in my test code it returns the users I created. This is about as far as I got.Relevant models:
The text was updated successfully, but these errors were encountered: