also looking at this
fix(client)!: bind db.raw and db.sql fragment values or refuse them
#1152
16 files
+455
-118
| @@ -200,11 +200,14 @@ const neverUpdated = await db | ||
| 200 | 200 | ## Raw Where Clauses |
| 201 | 201 | |
| 202 | 202 | ```typescript |
| 203 | import { raw } from 'bun-query-builder' | |
| 203 | 204 | |
| 204 | // Raw SQL in where | |
| 205 | // Raw SQL in where: one fragment, no bindings. The interpolated Date is | |
| 206 | // inlined as an escaped literal; use where() to bind request input. | |
| 207 | const since = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000) | |
| 205 | 208 | const activeRecent = await db |
| 206 | 209 | .selectFrom('users') |
| 207 | .whereRaw('DATE(created_at) > DATE_SUB(NOW(), INTERVAL 30 DAY)') | |
| 210 | .whereRaw(raw`created_at > ${since}`) | |
| 208 | 211 | .get() |
| 209 | 212 | |
| 210 | 213 | ``` |