(buf *strings.Builder, n *ast.UpdateStmt, sql string)
| 205 | } |
| 206 | |
| 207 | func writeUpdateSuffix(buf *strings.Builder, n *ast.UpdateStmt, sql string) error { |
| 208 | if n.Relation == nil { |
| 209 | return nil |
| 210 | } |
| 211 | |
| 212 | relText := extractNodeText(n.Relation.Loc, sql) |
| 213 | if _, err := fmt.Fprintf(buf, "FROM %s", relText); err != nil { |
| 214 | return errors.Wrap(err, "failed to write to buffer") |
| 215 | } |
| 216 | |
| 217 | if n.FromClause != nil && n.FromClause.Len() > 0 { |
| 218 | fromText := extractNodeText(ast.ListSpan(n.FromClause), sql) |
| 219 | if fromText != "" { |
| 220 | if _, err := fmt.Fprintf(buf, ", %s", fromText); err != nil { |
| 221 | return errors.Wrap(err, "failed to write to buffer") |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | if n.WhereClause != nil { |
| 227 | whereText := extractNodeText(ast.NodeLoc(n.WhereClause), sql) |
| 228 | if whereText != "" { |
| 229 | if _, err := fmt.Fprintf(buf, " WHERE %s", whereText); err != nil { |
| 230 | return errors.Wrap(err, "failed to write to buffer") |
| 231 | } |
| 232 | } |
| 233 | } |
| 234 | return nil |
| 235 | } |
| 236 | |
| 237 | func writeDeleteSuffix(buf *strings.Builder, n *ast.DeleteStmt, sql string) error { |
| 238 | if n.Relation == nil { |
no test coverage detected