MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / renderDelete

Function renderDelete

pkg/formatter/render.go:500–550  ·  view source on GitHub ↗
(d *ast.DeleteStatement, opts ast.FormatOptions)

Source from the content-addressed store, hash-verified

498}
499
500func renderDelete(d *ast.DeleteStatement, opts ast.FormatOptions) string {
501 if d == nil {
502 return ""
503 }
504 f := newNodeFormatter(opts)
505 sb := f.sb
506
507 if d.With != nil {
508 sb.WriteString(renderWith(d.With, f))
509 sb.WriteString(f.clauseSep())
510 }
511
512 sb.WriteString(f.kw("DELETE FROM"))
513 sb.WriteString(" ")
514 sb.WriteString(d.TableName)
515 if d.Alias != "" {
516 sb.WriteString(" ")
517 sb.WriteString(d.Alias)
518 }
519
520 if len(d.Using) > 0 {
521 sb.WriteString(f.clauseSep())
522 sb.WriteString(f.kw("USING"))
523 sb.WriteString(" ")
524 usings := make([]string, len(d.Using))
525 for i := range d.Using {
526 usings[i] = tableRefSQL(&d.Using[i], f)
527 }
528 sb.WriteString(strings.Join(usings, ", "))
529 }
530
531 if d.Where != nil {
532 sb.WriteString(f.clauseSep())
533 sb.WriteString(f.kw("WHERE"))
534 sb.WriteString(" ")
535 sb.WriteString(FormatExpression(d.Where, opts))
536 }
537
538 if len(d.Returning) > 0 {
539 sb.WriteString(f.clauseSep())
540 sb.WriteString(f.kw("RETURNING"))
541 sb.WriteString(" ")
542 sb.WriteString(exprListSQL(d.Returning))
543 }
544
545 if opts.AddSemicolon {
546 sb.WriteString(";")
547 }
548
549 return f.result()
550}
551
552func renderCreateTable(c *ast.CreateTableStatement, opts ast.FormatOptions) string {
553 if c == nil {

Callers 1

FormatStatementFunction · 0.85

Calls 8

newNodeFormatterFunction · 0.85
renderWithFunction · 0.85
FormatExpressionFunction · 0.85
clauseSepMethod · 0.80
kwMethod · 0.80
resultMethod · 0.80
tableRefSQLFunction · 0.70
exprListSQLFunction · 0.70

Tested by

no test coverage detected