(table: string, data: Record<string, unknown>, where: string)
| 91 | } |
| 92 | |
| 93 | export function buildUpdateQuery(table: string, data: Record<string, unknown>, where: string) { |
| 94 | validateWhereClause(where) |
| 95 | |
| 96 | const sanitizedTable = sanitizeIdentifier(table) |
| 97 | const columns = Object.keys(data) |
| 98 | const values = Object.values(data) |
| 99 | |
| 100 | const setClause = columns.map((col) => `${sanitizeIdentifier(col)} = ?`).join(', ') |
| 101 | const query = `UPDATE ${sanitizedTable} SET ${setClause} WHERE ${where}` |
| 102 | |
| 103 | return { query, values } |
| 104 | } |
| 105 | |
| 106 | export function buildDeleteQuery(table: string, where: string) { |
| 107 | validateWhereClause(where) |
no test coverage detected