mattiaferrari
mattiaferrari
DTDrizzle Team
Created by mattiaferrari on 11/14/2024 in #help
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?
sql`WHEN ${where} THEN ${value}`
sql`WHEN ${where} THEN ${value}`
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()
5 replies