SQL returns the SQL representation of this Update node (dml.go type). For the full-featured UPDATE use UpdateStatement.SQL() instead.
()
| 1201 | // SQL returns the SQL representation of this Update node (dml.go type). |
| 1202 | // For the full-featured UPDATE use UpdateStatement.SQL() instead. |
| 1203 | func (u *Update) SQL() string { |
| 1204 | if u == nil { |
| 1205 | return "" |
| 1206 | } |
| 1207 | sb := getBuilder() |
| 1208 | defer putBuilder(sb) |
| 1209 | sb.WriteString("UPDATE ") |
| 1210 | sb.WriteString(tableRefSQL(&u.Table)) |
| 1211 | sb.WriteString(" SET ") |
| 1212 | upds := make([]string, len(u.Updates)) |
| 1213 | for i, upd := range u.Updates { |
| 1214 | upds[i] = exprSQL(upd.Column) + " = " + exprSQL(upd.Value) |
| 1215 | } |
| 1216 | sb.WriteString(strings.Join(upds, ", ")) |
| 1217 | if u.Where != nil { |
| 1218 | sb.WriteString(" WHERE ") |
| 1219 | sb.WriteString(exprSQL(u.Where)) |
| 1220 | } |
| 1221 | if len(u.ReturningClause) > 0 { |
| 1222 | sb.WriteString(" RETURNING ") |
| 1223 | sb.WriteString(exprListSQL(u.ReturningClause)) |
| 1224 | } |
| 1225 | return sb.String() |
| 1226 | } |
| 1227 | |
| 1228 | // SQL returns the SQL representation of this Delete node (dml.go type). |
| 1229 | // For the full-featured DELETE use DeleteStatement.SQL() instead. |