enalmada
DTDrizzle Team
•Created by enalmada on 8/24/2023 in #help
parameterized insert and update
@micaww the
value.toISOString is not a function
error is actually happening on page load when the statement is being parameterized before any data. I do believe I am ultimately passing in a Date object on execution but I need to confim.
FYI I created this bug to track the { mode: 'Date' } issue with timestamp parameters https://github.com/drizzle-team/drizzle-orm/issues/1113
With that out of the way I think I am finding that parameterized insert doesn't respect the new default id logic (not too surprising as it is very new https://github.com/drizzle-team/drizzle-orm/releases/tag/0.28.3). I believe I can work around that by just passing my own id in.
11 replies
DTDrizzle Team
•Created by enalmada on 8/24/2023 in #help
parameterized insert and update
I was able to get around my
value.toISOString is not a function
problem with insert paramaterized timestamps by switching schema of timestamp to { mode: 'string' }
11 replies
DTDrizzle Team
•Created by enalmada on 8/24/2023 in #help
parameterized insert and update
Thanks @micaww for your help. I do believe the placeholder is necessary for prepared statements. When I remove sql.placeholder from the where of a prepared statement it doesn't seem to work. I was trying to follow this as close as possible.
https://orm.drizzle.team/docs/performance#placeholder
I assume this should be the right syntax for Insert:
But I get
And when doing update I get a typescript error on the set key dueDate.
TS2322: Type Placeholder<"dueDate", any> is not assignable to type SQL<unknown> | Date | null | undefined
Type Placeholder<"dueDate", any> is missing the following properties from type SQL<unknown> : queryChunks, _, shouldInlineParams, append , and 6 more.
So I think I am having two separate problems with insert and update parameterization that the following just happens to get around
11 replies
DTDrizzle Team
•Created by enalmada on 8/24/2023 in #help
parameterized insert and update
It actually looks like this might be working:
Is that the recommended syntax or is there a more official way to avoid wrapping the placeholder in sql
...
?11 replies