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

Function TestCTESQL

pkg/sql/ast/sql_test.go:235–246  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

233}
234
235func TestCTESQL(t *testing.T) {
236 inner := &SelectStatement{Columns: []Expression{&Identifier{Name: "*"}}, From: []TableReference{{Name: "orders"}}, Where: &BinaryExpression{Left: &Identifier{Name: "total"}, Operator: ">", Right: &LiteralValue{Value: 100, Type: "INTEGER"}}}
237 stmt := &SelectStatement{
238 With: &WithClause{CTEs: []*CommonTableExpr{{Name: "big_orders", Statement: inner}}},
239 Columns: []Expression{&Identifier{Name: "*"}},
240 From: []TableReference{{Name: "big_orders"}},
241 }
242 want := "WITH big_orders AS (SELECT * FROM orders WHERE total > 100) SELECT * FROM big_orders"
243 if got := stmt.SQL(); got != want {
244 t.Errorf("SQL() =\n %s\nwant:\n %s", got, want)
245 }
246}
247
248func TestSetOperationSQL(t *testing.T) {
249 stmt := &SetOperation{

Callers

nothing calls this directly

Calls 2

SQLMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected