(ctx Context, m *qcode.Mutate, qc *qcode.QCode, varName string, renderColVal func(qcode.MColumn))
| 799 | } |
| 800 | |
| 801 | func (d *SQLiteDialect) RenderLinearInsert(ctx Context, m *qcode.Mutate, qc *qcode.QCode, varName string, renderColVal func(qcode.MColumn)) { |
| 802 | // Capture all inserted IDs using a temporary trigger (if not capturing via simple RETURNING) |
| 803 | // But SQLite now supports RETURNING so we use that at end. |
| 804 | |
| 805 | ctx.WriteString("INSERT INTO ") |
| 806 | ctx.ColWithTable(m.Ti.Schema, m.Ti.Name) |
| 807 | ctx.WriteString(" (") |
| 808 | i := 0 |
| 809 | for _, col := range m.Cols { |
| 810 | if i != 0 { |
| 811 | ctx.WriteString(", ") |
| 812 | } |
| 813 | ctx.Quote(col.Col.Name) |
| 814 | i++ |
| 815 | } |
| 816 | for _, rcol := range m.RCols { |
| 817 | if i != 0 { |
| 818 | ctx.WriteString(", ") |
| 819 | } |
| 820 | ctx.Quote(rcol.Col.Name) |
| 821 | i++ |
| 822 | } |
| 823 | ctx.WriteString(")") |
| 824 | |
| 825 | if m.IsJSON { |
| 826 | ctx.WriteString(" SELECT ") |
| 827 | } else { |
| 828 | ctx.WriteString(" VALUES (") |
| 829 | } |
| 830 | |
| 831 | i = 0 |
| 832 | for _, col := range m.Cols { |
| 833 | if i != 0 { |
| 834 | ctx.WriteString(", ") |
| 835 | } |
| 836 | renderColVal(col) |
| 837 | i++ |
| 838 | } |
| 839 | for _, rcol := range m.RCols { |
| 840 | if i != 0 { |
| 841 | ctx.WriteString(", ") |
| 842 | } |
| 843 | found := false |
| 844 | for id := range m.DependsOn { |
| 845 | if qc.Mutates[id].Ti.Name == rcol.VCol.Table { |
| 846 | d.RenderVar(ctx, d.getVarName(qc.Mutates[id])) |
| 847 | found = true |
| 848 | break |
| 849 | } |
| 850 | } |
| 851 | if !found { |
| 852 | ctx.WriteString("NULL") |
| 853 | } |
| 854 | i++ |
| 855 | } |
| 856 | |
| 857 | if m.IsJSON { |
| 858 | ctx.WriteString(" FROM ") |
nothing calls this directly
no test coverage detected