Lloyd
Lloyd
DTDrizzle Team
Created by Lloyd on 6/11/2024 in #help
Top-level await in drizzle.config.ts
Is there a reason top-level await is only supported in migrate/studio commands and not generate/check, is this something that can be trivially added to drizzle-kit? In my case I'm reading the secret asynchronously via AWS. There's an open issue with a workaround posted, which does work, but is kind of gross: https://github.com/drizzle-team/drizzle-orm/issues/1982#issuecomment-2112340840
1 replies
DTDrizzle Team
Created by Lloyd on 5/2/2024 in #help
Postgres.js type error string/date
I'm running the following where clause in a select query:
.where(
and(
gt(
sql`${e.originalStartTime} + (${p.endTime} - ${p.startTime})::interval`,
${endingAfter},
),
lt(e.originalStartTime, ${startingBefore),
),
)
.where(
and(
gt(
sql`${e.originalStartTime} + (${p.endTime} - ${p.startTime})::interval`,
${endingAfter},
),
lt(e.originalStartTime, ${startingBefore),
),
)
When printing out the query with parameters, the value for endingAfter is a Date, and has not been turned into a string:
[
2024-01-01T00:00:00Z // endingAfter
'2024-12-31T00:00:00Z' // startingBefore works fine
]
[
2024-01-01T00:00:00Z // endingAfter
'2024-12-31T00:00:00Z' // startingBefore works fine
]
...with the error:
The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Date
The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Date
This works fine when I perform .toISOString() on endingAfter, but it doesn't seem to do that automatically in this case, I assume because it doesn't have the column information because the first arguments is an SQL<unknown>. I've tried various things to get this right; using a type parameter for the sql, using .mapWith() with a timestamp column, but haven't managed to come up with the correct magic. I've noted the postgres-js breaking changes in 0.3 around strings/Dates, which is why I have just used .toISOString() for now, but this feels like it should work because it works in the other examples where there is column information present Thanks!
1 replies