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

Method SQL

pkg/sql/ast/sql.go:735–774  ·  view source on GitHub ↗

SQL returns the full SQL string for this DELETE statement, including the optional WITH clause, USING clause, WHERE condition, and RETURNING clause.

()

Source from the content-addressed store, hash-verified

733// SQL returns the full SQL string for this DELETE statement, including the
734// optional WITH clause, USING clause, WHERE condition, and RETURNING clause.
735func (d *DeleteStatement) SQL() string {
736 if d == nil {
737 return ""
738 }
739 sb := getBuilder()
740 defer putBuilder(sb)
741
742 if d.With != nil {
743 sb.WriteString(d.With.SQL())
744 sb.WriteString(" ")
745 }
746
747 sb.WriteString("DELETE FROM ")
748 sb.WriteString(d.TableName)
749 if d.Alias != "" {
750 sb.WriteString(" ")
751 sb.WriteString(d.Alias)
752 }
753
754 if len(d.Using) > 0 {
755 sb.WriteString(" USING ")
756 usings := make([]string, len(d.Using))
757 for i := range d.Using {
758 usings[i] = tableRefSQL(&d.Using[i])
759 }
760 sb.WriteString(strings.Join(usings, ", "))
761 }
762
763 if d.Where != nil {
764 sb.WriteString(" WHERE ")
765 sb.WriteString(exprSQL(d.Where))
766 }
767
768 if len(d.Returning) > 0 {
769 sb.WriteString(" RETURNING ")
770 sb.WriteString(exprListSQL(d.Returning))
771 }
772
773 return sb.String()
774}
775
776// SQL returns the full SQL string for this CREATE TABLE statement including
777// column definitions, table constraints, INHERITS, PARTITION BY, and table options.

Callers 3

TestNilSQLFunction · 0.95
TestDeleteStatementSQLFunction · 0.95

Calls 7

getBuilderFunction · 0.85
putBuilderFunction · 0.85
tableRefSQLFunction · 0.70
exprSQLFunction · 0.70
exprListSQLFunction · 0.70
SQLMethod · 0.45
StringMethod · 0.45

Tested by 3

TestNilSQLFunction · 0.76
TestDeleteStatementSQLFunction · 0.76