create-t3-turbo icon indicating copy to clipboard operation
create-t3-turbo copied to clipboard

bug: can't use sql in $onUpdateFn, value.toISOString is not a function

Open trevorpfiz opened this issue 1 year ago • 4 comments

Provide environment information

System: OS: Linux 5.15 Ubuntu 20.04.6 LTS (Focal Fossa) CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor Memory: 3.74 GB / 9.72 GB Container: Yes Shell: 5.8 - /usr/bin/zsh Binaries: Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm pnpm: 9.2.0 - ~/.nvm/versions/node/v20.12.2/bin/pnpm bun: 1.0.29 - ~/.bun/bin/bun

Describe the bug

tRPC Error on 'post.update'  [TRPCError: value.toISOString is not a function] {
  code: 'INTERNAL_SERVER_ERROR',
  name: 'TRPCError'
}

It seems that we can't use sql in $onUpdateFn? Did this used to work? https://github.com/drizzle-team/drizzle-orm/issues/2212#issuecomment-2114083803

Link to reproduction

https://github.com/t3-oss/create-t3-turbo

To reproduce

Update a post

Additional information

No response

trevorpfiz avatar Jun 29 '24 10:06 trevorpfiz

@trevorpfiz looks not related with this repo. am i missing something?

necmettindev avatar Jun 29 '24 14:06 necmettindev

@trevorpfiz looks not related with this repo. am i missing something?

https://github.com/t3-oss/create-t3-turbo/blob/791c06f64f736bb28eeab832e848ae812a67066f/packages/db/src/schema.ts#L22

trevorpfiz avatar Jul 01 '24 19:07 trevorpfiz

still an issue.https://github.com/drizzle-team/drizzle-orm/issues/2212 works with mode: string when update db.

childrentime avatar Jul 29 '24 10:07 childrentime

I encounter the same question and solve it by changing the callback to:

updatedAt: timestamp("updated_at", {
    mode: "date",
    withTimezone: true,
  }).$onUpdateFn(() => new Date()),

See also https://github.com/drizzle-team/drizzle-orm/issues/1113 https://github.com/drizzle-team/drizzle-orm/issues/2212

soulful-ramble avatar Sep 12 '24 04:09 soulful-ramble