| 83 | } |
| 84 | |
| 85 | func (s *StmtSuite) TestSelectCopy(c *gc.C) { |
| 86 | q := table1.Select(table1Col1).Where(GtL(table1Col1, 123)) |
| 87 | qq := q.Copy().Where(GtL(table1Col1, 321)).OrderBy(table1Col1) |
| 88 | |
| 89 | // Initial query unchanged |
| 90 | sql, err := q.String("db") |
| 91 | c.Assert(err, gc.IsNil) |
| 92 | c.Assert( |
| 93 | sql, |
| 94 | gc.Equals, |
| 95 | "SELECT `table1`.`col1` FROM `db`.`table1` WHERE `table1`.`col1`>123") |
| 96 | // New query changed |
| 97 | sql, err = qq.String("db") |
| 98 | c.Assert(err, gc.IsNil) |
| 99 | c.Assert( |
| 100 | sql, |
| 101 | gc.Equals, |
| 102 | "SELECT `table1`.`col1` FROM `db`.`table1` WHERE `table1`.`col1`>321 ORDER BY `table1`.`col1`") |
| 103 | |
| 104 | } |
| 105 | |
| 106 | func (s *StmtSuite) TestSelectLimitWithoutOffset(c *gc.C) { |
| 107 | q := table1.Select(table1Col1).Limit(5) |