Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connected fields do not get an updated by @updatedAt #4146

Closed
Sytten opened this issue Nov 3, 2020 · 2 comments · Fixed by prisma/prisma-engines#1465
Closed

Connected fields do not get an updated by @updatedAt #4146

Sytten opened this issue Nov 3, 2020 · 2 comments · Fixed by prisma/prisma-engines#1465
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. tech/engines Issue for tech Engines. topic: prisma-client
Milestone

Comments

@Sytten
Copy link
Contributor

Sytten commented Nov 3, 2020

Bug description

Consider the following query:

await app.prisma.account.create({
    data: {
      name,
      tokens: {
        connect: tokens.map(t => ({ id: t.id })),
      },
    },
  })

with the following schema:

model Account {
  id         String         @id @default(cuid())
  tokens     Token[]
  updatedAt  DateTime       @updatedAt
}

model Token {
  account      Account? @relation(fields: [accountId], references: [id])
  accountId    String?
  id           String   @id @default(cuid())
  updatedAt    DateTime @updatedAt
}

One would expect that the updatedAt of the Token model would get updated on connect, but it is not the case. The following SQL is executed:

 UPDATE "public"."Token" SET "accountId" = $1 WHERE "public"."Token"."id" IN ($2,$3)
@matthewmueller matthewmueller added topic: prisma-client bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. tech/engines Issue for tech Engines. kind/bug A reported bug. labels Nov 3, 2020
@pantharshit00 pantharshit00 added bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Nov 10, 2020
@pantharshit00
Copy link
Contributor

I can confirm the behavior. We should fix this as write does happen on the token table.

@yoshuawuyts
Copy link

This has been resolved in prisma/prisma-engines#1465 and should be part of our next release -- thanks again for reporting @Sytten!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. tech/engines Issue for tech Engines. topic: prisma-client
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants