could not determine data type of parameter $2

export function duration(duration: string) {
return sql`now() + interval '${duration}'`;
}
export function duration(duration: string) {
return sql`now() + interval '${duration}'`;
}
Whats wrong?
3 Replies
ly
lyOP3mo ago
bump
rphlmr ⚡
rphlmr ⚡3mo ago
export function duration(duration: string) {
return sql.raw(`now() + interval '${duration}'`);
// return sql`now() + interval '${sql.raw(duration)}'`; // or
}
export function duration(duration: string) {
return sql.raw(`now() + interval '${duration}'`);
// return sql`now() + interval '${sql.raw(duration)}'`; // or
}
You are in this case: https://orm.drizzle.team/docs/sql#sqlraw when you inject from a function param in a raw query
Drizzle ORM - Magic sql`` operator
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Want results from more Discord servers?
Add your server