| 126 | } |
| 127 | |
| 128 | func (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 | |
| 145 | func (s *StmtSuite) TestSelectSingleOrderBy(c *gc.C) { |
| 146 | q := table1.Select(table1Col1, table1Col2).OrderBy(table1Col2) |