sql magic operator with dates?
We were using drizzle orm but We implemented by ourselves a "multi-update" query to update fields based on different primary keys using the
CASE ... THEN
postgres syntax, this forced us to use the sql magic operator.
Is there a way to integrate the sql magic operator with the timestamp
type or with other custom types?
It seems that doing something like this does not apply the correct parsing on timestamps or defined custom types. Date in javascript doesnt use the correct toString function and the update expects a string so we had to manually check for a date object and apply .toISOString()
2 Replies
When you use the sql operator you have to do that manually
But there is an undocumented method in the sql operator to make this type of stuff easier to operate
You could use it like this:
In the case when you want to use the decoder in the createdAt column of the users table
See this example https://drizzle.run/vihy2j6udcupo6u525z55u22