| 1 | import { type SQL, sql } from 'drizzle-orm'; |
| 2 | import { toSnakeCase } |
| 3 | import type { AnyPgColumn |
| 4 | |
| 5 | // Timestamps leave the database already in the shape responses promise, so nothing downstream has to convert them. The format matches `Date.prototype.toISOString` byte for byte. |
| 6 | export function isoTimestamp(column |
| 7 | return sql<string |
| 8 | } |
| 9 | |
| 10 | /** The value an upsert tried to insert, for `onConflictDoUpdate`. The database names columns in snake_case, however the schema spells them. */ |
| 11 | export function excluded(column |
| 12 | return sql.raw |
| 13 | } |
| 14 | |
| 15 | // For `ilike`: a search for "50%" or "a_b" matches those characters, not any. |
| 16 | export function escapeLike(value |
| 17 | return value.replace |
| 18 | } |