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

Function TestWindowFunctionSQL

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

Source from the content-addressed store, hash-verified

222}
223
224func TestWindowFunctionSQL(t *testing.T) {
225 stmt := &SelectStatement{
226 Columns: []Expression{&FunctionCall{Name: "ROW_NUMBER", Over: &WindowSpec{PartitionBy: []Expression{&Identifier{Name: "dept_id"}}, OrderBy: []OrderByExpression{{Expression: &Identifier{Name: "salary"}, Ascending: false}}}}},
227 From: []TableReference{{Name: "employees"}},
228 }
229 want := "SELECT ROW_NUMBER() OVER (PARTITION BY dept_id ORDER BY salary DESC) FROM employees"
230 if got := stmt.SQL(); got != want {
231 t.Errorf("SQL() =\n %s\nwant:\n %s", got, want)
232 }
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"}}}

Callers

nothing calls this directly

Calls 2

SQLMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected