─── SET OPERATIONS ──────────────────────────────────────────────────────────
(t *testing.T)
| 397 | // ─── SET OPERATIONS ────────────────────────────────────────────────────────── |
| 398 | |
| 399 | func TestRenderSetOperation(t *testing.T) { |
| 400 | s := &ast.SetOperation{ |
| 401 | Left: &ast.SelectStatement{Columns: []ast.Expression{&ast.Identifier{Name: "a"}}, From: []ast.TableReference{{Name: "t1"}}}, |
| 402 | Right: &ast.SelectStatement{Columns: []ast.Expression{&ast.Identifier{Name: "b"}}, From: []ast.TableReference{{Name: "t2"}}}, |
| 403 | Operator: "UNION", |
| 404 | All: true, |
| 405 | } |
| 406 | result := fmtStmt(s, ast.ReadableStyle()) |
| 407 | if !strings.Contains(result, "UNION ALL") { |
| 408 | t.Errorf("expected UNION ALL, got: %s", result) |
| 409 | } |
| 410 | if !strings.HasSuffix(strings.TrimSpace(result), ";") { |
| 411 | t.Error("ReadableStyle should add semicolon") |
| 412 | } |
| 413 | |
| 414 | compact := fmtStmt(s, ast.CompactStyle()) |
| 415 | if strings.Contains(compact, "\n") { |
| 416 | t.Errorf("compact should be single line: %s", compact) |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | func TestRenderSetOperation_Nil(t *testing.T) { |
| 421 | var s *ast.SetOperation |
nothing calls this directly
no test coverage detected