Skip to content

Commit 0e6e16e

Browse files
committed
fix #74 [BREAKING CHANGE] Select#GroupBy and Select#OrderBy behavior change.
Previous, GroupBy and OrderBy only keep the columns in the last call. Now, all columns are kept.
1 parent 153aee0 commit 0e6e16e

File tree

4 files changed

+3
-9
lines changed

4 files changed

+3
-9
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/huandu/go-sqlbuilder
22

3-
go 1.12
3+
go 1.13
44

55
require (
66
github.com/huandu/go-assert v1.1.5

injection.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ type injection struct {
1515

1616
type injectionMarker int
1717

18-
type injectedSQL struct {
19-
marker injectionMarker
20-
sql string
21-
}
22-
2318
// newInjection creates a new injection.
2419
func newInjection() *injection {
2520
return &injection{

select.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,14 @@ func (sb *SelectBuilder) Having(andExpr ...string) *SelectBuilder {
153153

154154
// GroupBy sets columns of GROUP BY in SELECT.
155155
func (sb *SelectBuilder) GroupBy(col ...string) *SelectBuilder {
156-
sb.groupByCols = col
156+
sb.groupByCols = append(sb.groupByCols, col...)
157157
sb.marker = selectMarkerAfterGroupBy
158158
return sb
159159
}
160160

161161
// OrderBy sets columns of ORDER BY in SELECT.
162162
func (sb *SelectBuilder) OrderBy(col ...string) *SelectBuilder {
163-
sb.orderByCols = col
163+
sb.orderByCols = append(sb.orderByCols, col...)
164164
sb.marker = selectMarkerAfterOrderBy
165165
return sb
166166
}

struct_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ func (db testDB) Query(query string, args ...interface{}) (testRows, error) {
245245
}
246246

247247
func (db testDB) Exec(query string, args ...interface{}) {
248-
return
249248
}
250249

251250
func (rows testRows) Close() error {

0 commit comments

Comments
 (0)