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

Method SQL

pkg/sql/ast/sql.go:1203–1226  ·  view source on GitHub ↗

SQL returns the SQL representation of this Update node (dml.go type). For the full-featured UPDATE use UpdateStatement.SQL() instead.

()

Source from the content-addressed store, hash-verified

1201// SQL returns the SQL representation of this Update node (dml.go type).
1202// For the full-featured UPDATE use UpdateStatement.SQL() instead.
1203func (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.

Callers 2

TestUpdate_SQLFunction · 0.95
TestNilSQLFunction · 0.95

Calls 6

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

Tested by 2

TestUpdate_SQLFunction · 0.76
TestNilSQLFunction · 0.76