(params: {
engine: Engine;
schema: string | undefined;
table: string;
columns: string[];
rows: RowValue[][];
})
| 322 | // the given rows. Each `rows[i]` is the cell array of one result row, aligned |
| 323 | // with `columns`. |
| 324 | export const generateInsertStatementFromRows = (params: { |
| 325 | engine: Engine; |
| 326 | schema: string | undefined; |
| 327 | table: string; |
| 328 | columns: string[]; |
| 329 | rows: RowValue[][]; |
| 330 | }): string => { |
| 331 | const { engine, schema, table, columns, rows } = params; |
| 332 | const schemaAndTable = generateSchemaAndTableNameInSQL( |
| 333 | engine, |
| 334 | schema ?? "", |
| 335 | table |
| 336 | ); |
| 337 | const columnNames = columns |
| 338 | .map((column) => wrapSQLIdentifier(column, engine)) |
| 339 | .join(", "); |
| 340 | const valueLines = rows |
| 341 | .map( |
| 342 | (row) => |
| 343 | ` (${row.map((cell) => rowValueToSQLLiteral(cell, engine)).join(", ")})` |
| 344 | ) |
| 345 | .join(",\n"); |
| 346 | return `INSERT INTO ${schemaAndTable} (${columnNames}) VALUES\n${valueLines};`; |
| 347 | }; |
| 348 | |
| 349 | export const generateSimpleUpdateStatement = ( |
| 350 | engine: Engine, |
no test coverage detected