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

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

Open
trevorpfiz opened this issue Jun 29, 2024 · 4 comments
Open

Comments

@trevorpfiz
Copy link

trevorpfiz commented Jun 29, 2024

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? drizzle-team/drizzle-orm#2212 (comment)

Link to reproduction

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

To reproduce

Update a post

Additional information

No response

@necmettindev
Copy link
Contributor

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

@trevorpfiz
Copy link
Author

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

}).$onUpdateFn(() => sql`now()`),

@childrentime
Copy link

still an issue.drizzle-team/drizzle-orm#2212 works with mode: string when update db.

@soulful-ramble
Copy link
Contributor

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
drizzle-team/drizzle-orm#1113
drizzle-team/drizzle-orm#2212

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants