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

Function TestRenderUpdate_AllClauses

pkg/formatter/render_test.go:254–272  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

252}
253
254func TestRenderUpdate_AllClauses(t *testing.T) {
255 stmt := &ast.UpdateStatement{
256 With: &ast.WithClause{CTEs: []*ast.CommonTableExpr{
257 {Name: "c", Statement: &ast.SelectStatement{Columns: []ast.Expression{&ast.Identifier{Name: "x"}}}},
258 }},
259 TableName: "t",
260 Alias: "tt",
261 Assignments: []ast.UpdateExpression{{Column: &ast.Identifier{Name: "x"}, Value: &ast.LiteralValue{Value: "1"}}},
262 From: []ast.TableReference{{Name: "other"}},
263 Where: &ast.Identifier{Name: "true"},
264 Returning: []ast.Expression{&ast.Identifier{Name: "id"}},
265 }
266 result := fmtStmt(stmt, ast.ReadableStyle())
267 for _, want := range []string{"WITH", "UPDATE t tt", "SET", "FROM", "WHERE", "RETURNING"} {
268 if !strings.Contains(result, want) {
269 t.Errorf("missing %q in: %s", want, result)
270 }
271 }
272}
273
274func TestRenderUpdate_Nil(t *testing.T) {
275 var stmt *ast.UpdateStatement

Callers

nothing calls this directly

Calls 3

ReadableStyleFunction · 0.92
fmtStmtFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected