MCPcopy Index your code
hub / github.com/dropbox/godropbox / TestSelectGroupBy

Method TestSelectGroupBy

database/sqlbuilder/statement_test.go:128–143  ·  view source on GitHub ↗
(c *gc.C)

Source from the content-addressed store, hash-verified

126}
127
128func (s *StmtSuite) TestSelectGroupBy(c *gc.C) {
129 q := table1.Select(
130 table1Col1,
131 table1Col2,
132 Alias("total", SqlFunc("sum", table1Col3)))
133 q.GroupBy(table1Col1, table1Col2)
134 sql, err := q.String("db")
135
136 c.Assert(err, gc.IsNil)
137 c.Assert(
138 sql,
139 gc.Equals,
140 "SELECT `table1`.`col1`,`table1`.`col2`,"+
141 "(sum(`table1`.`col3`)) AS `total` "+
142 "FROM `db`.`table1` GROUP BY `table1`.`col1`,`table1`.`col2`")
143}
144
145func (s *StmtSuite) TestSelectSingleOrderBy(c *gc.C) {
146 q := table1.Select(table1Col1, table1Col2).OrderBy(table1Col2)

Callers

nothing calls this directly

Calls 5

AliasFunction · 0.85
SqlFuncFunction · 0.85
SelectMethod · 0.65
GroupByMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected