MCPcopy
hub / github.com/ent/ent / TestWindowFunction_Select

Function TestWindowFunction_Select

dialect/sql/builder_test.go:2101–2114  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2099}
2100
2101func TestWindowFunction_Select(t *testing.T) {
2102 posts := Table("posts")
2103 q := Select().
2104 AppendSelect("*").
2105 AppendSelectExprAs(
2106 Window(func(b *Builder) {
2107 b.WriteString(Sum(posts.C("duration")))
2108 }).PartitionBy("author_id").OrderBy("id"), "duration").
2109 From(posts)
2110
2111 query, args := q.Query()
2112 require.Equal(t, "SELECT *, (SUM(`posts`.`duration`) OVER (PARTITION BY `author_id` ORDER BY `id`)) AS `duration` FROM `posts`", query)
2113 require.Nil(t, args)
2114}
2115
2116func TestSelector_UnqualifiedColumns(t *testing.T) {
2117 t1, t2 := Table("t1"), Table("t2")

Callers

nothing calls this directly

Calls 12

WindowFunction · 0.85
AppendSelectExprAsMethod · 0.80
AppendSelectMethod · 0.80
PartitionByMethod · 0.80
WriteStringMethod · 0.80
TableFunction · 0.70
SelectFunction · 0.70
SumFunction · 0.70
CMethod · 0.65
QueryMethod · 0.65
FromMethod · 0.45
OrderByMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…