Sql cleanups

This commit is contained in:
Zoe Roux
2025-04-07 23:34:33 +02:00
parent 69006478cb
commit 4cf67c3247
3 changed files with 25 additions and 19 deletions
+5 -1
View File
@@ -95,10 +95,14 @@ export function values(items: Record<string, unknown>[]) {
};
}
export const coalesce = <T>(val: SQL<T> | Column, def: SQL<T>) => {
export const coalesce = <T>(val: SQL<T> | Column, def: SQL<T> | Column) => {
return sql<T>`coalesce(${val}, ${def})`;
};
export const nullif = <T>(val: SQL<T> | Column, eq: SQL<T>) => {
return sql<T>`nullif(${val}, ${eq})`;
};
export const jsonbObjectAgg = <T>(key: SQLWrapper, value: SQL<T>) => {
return sql<
Record<string, T>