(ctx Context, m *qcode.Mutate, renderBody func())
| 612 | } |
| 613 | |
| 614 | func (d *SQLiteDialect) RenderMutationCTE(ctx Context, m *qcode.Mutate, renderBody func()) { |
| 615 | // SQLite supports CTEs but not writable CTEs data-modifying CTEs (INSERT inside WITH). |
| 616 | // So we render the body directly (INSERT ...) so it becomes the main statement. |
| 617 | // We inject a dummy CTE to consume the trailing comma from the previous CTE (e.g. input variables). |
| 618 | // Result: `WITH input AS (...), "ignored_<table>_<id>" AS (SELECT 1) INSERT ...` |
| 619 | var cteName string |
| 620 | if m.Multi { |
| 621 | cteName = fmt.Sprintf("ignored_%s_%d", m.Ti.Name, m.ID) |
| 622 | } else { |
| 623 | cteName = "ignored_" + m.Ti.Name |
| 624 | } |
| 625 | ctx.Quote(cteName) |
| 626 | ctx.WriteString(` AS (SELECT 1) `) |
| 627 | renderBody() |
| 628 | } |
| 629 | |
| 630 | func (d *SQLiteDialect) RenderInsert(ctx Context, m *qcode.Mutate, values func()) { |
| 631 | ctx.WriteString(`INSERT INTO `) |
nothing calls this directly
no test coverage detected