(ctx Context, m *qcode.Mutate, qc *qcode.QCode, varName string, renderColVal func(qcode.MColumn), renderWhere func())
| 872 | } |
| 873 | |
| 874 | func (d *SQLiteDialect) RenderLinearUpdate(ctx Context, m *qcode.Mutate, qc *qcode.QCode, varName string, renderColVal func(qcode.MColumn), renderWhere func()) { |
| 875 | var fromFunc func() |
| 876 | if m.IsJSON { |
| 877 | fromFunc = func() { |
| 878 | d.RenderMutateToRecordSet(ctx, m, 0, func() { |
| 879 | ctx.AddParam(Param{Name: qc.ActionVar, Type: "json"}) |
| 880 | }) |
| 881 | } |
| 882 | } |
| 883 | |
| 884 | |
| 885 | d.RenderUpdate(ctx, m, func() { |
| 886 | // Set |
| 887 | i := 0 |
| 888 | for _, col := range m.Cols { |
| 889 | if i != 0 { |
| 890 | ctx.WriteString(", ") |
| 891 | } |
| 892 | // SQLite restriction on qualified column names in SET |
| 893 | ctx.Quote(col.Col.Name) |
| 894 | ctx.WriteString(" = ") |
| 895 | renderColVal(col) |
| 896 | i++ |
| 897 | } |
| 898 | for range m.RCols { |
| 899 | // For SQLite updates, we don't want to update the relationship columns |
| 900 | // in the SET clause, as we handle the join in the WHERE clause? |
| 901 | // mutate.go logic: line 329: if c.dialect.Name() == "sqlite" { continue } |
| 902 | // So we skip them here. |
| 903 | continue |
| 904 | } |
| 905 | |
| 906 | if i == 0 { |
| 907 | for j, pkCol := range m.Ti.PrimaryCols { |
| 908 | if j > 0 { |
| 909 | ctx.WriteString(`, `) |
| 910 | } |
| 911 | ctx.Quote(pkCol.Name) |
| 912 | ctx.WriteString(" = ") |
| 913 | ctx.Quote(pkCol.Name) |
| 914 | } |
| 915 | } |
| 916 | }, fromFunc, func() { |
| 917 | // Where |
| 918 | // Logic from mutate.go lines 402+ |
| 919 | // c.renderExp(path...) |
| 920 | |
| 921 | // Also handle join conditions. |
| 922 | // mutate.go: if m.ParentID != -1 ... AND childCol = (SELECT parentCol FROM ... WHERE ...) |
| 923 | |
| 924 | renderWhere() // Renders m.Where.Exp |
| 925 | }) |
| 926 | |
| 927 | d.RenderReturning(ctx, m) |
| 928 | ctx.WriteString(" -- @gj_ids=") |
| 929 | ctx.WriteString(varName) |
| 930 | ctx.WriteString("\n; ") |
| 931 | } |
nothing calls this directly
no test coverage detected