Hello prisma team, I have a doubt with respect to...
# orm-help
n
Hello prisma team, I have a doubt with respect to raw queries. So I have the below model (Using
Postgres
as DB)
Copy code
model Test {
  id String @id @default(uuid())

  name           String

  // common fields
  createdAt DateTime @default(now()) @map("created_at")
  updatedAt DateTime @default(now()) @updatedAt @map("updated_at")

  @@map("test")
}
and using below code snippet in node js.
Copy code
async function update() {
      // Node js
      // Current state of the row in the DB
      await model.test.findUnique({ where: { id: 1 } });
      // { id: 1, name: "current_value", updated_at: "2021-06-30T11:00:16.291Z", created_at: "2021-06-30T11:00:16.291Z"}
      await model.test.updateMany({ data: { name: "after_update" } });
      // { id: 1, name: "after_update", updated_at: "2021-06-30T12:00:16.291Z", created_at: "2021-06-30T11:00:16.291Z"}
      await model.$queryRaw(`UPDATE test set name = 'updater_after_raw'`); // @rawQuery
      // { id: 1, name: "updater_after_raw", updated_at: "2021-06-30T12:00:16.291Z", created_at: "2021-06-30T11:00:16.291Z"}
    }
Here after
@rawQuery
,
update_at
field is not being updated. Couldn't understand this behaviour. Is this intentional or any issue? Expected behaviour - It should update the
updated_at
field when I am writing raw update query in prisma.
r
@Nimish Gupta 👋 What version of Prisma are you on?
Opened an issue here.
n
I am using these versions
Copy code
{
  "@prisma/client": "^2.26.0",
  "prisma": "^2.26.0"
}
Thanks for this.
r
As a workaround, you could pass the current date to
updatedAt
in the raw query for now. Not ideal but until this is fixed 😄
n
Ah ok ok, yeah I can put updatedAt in rawQuery, thanks for the suggestion.
🙌 1