Skip to content

Commit

Permalink
fix #74 [BREAKING CHANGE] Select#GroupBy and Select#OrderBy behavior …
Browse files Browse the repository at this point in the history
…change.

Previous, GroupBy and OrderBy only keep the columns in the last call. Now, all columns are kept.
  • Loading branch information
huandu committed Jun 23, 2022
1 parent 153aee0 commit 0e6e16e
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/huandu/go-sqlbuilder

go 1.12
go 1.13

require (
github.com/huandu/go-assert v1.1.5
Expand Down
5 changes: 0 additions & 5 deletions injection.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ type injection struct {

type injectionMarker int

type injectedSQL struct {
marker injectionMarker
sql string
}

// newInjection creates a new injection.
func newInjection() *injection {
return &injection{
Expand Down
4 changes: 2 additions & 2 deletions select.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ func (sb *SelectBuilder) Having(andExpr ...string) *SelectBuilder {

// GroupBy sets columns of GROUP BY in SELECT.
func (sb *SelectBuilder) GroupBy(col ...string) *SelectBuilder {
sb.groupByCols = col
sb.groupByCols = append(sb.groupByCols, col...)
sb.marker = selectMarkerAfterGroupBy
return sb
}

// OrderBy sets columns of ORDER BY in SELECT.
func (sb *SelectBuilder) OrderBy(col ...string) *SelectBuilder {
sb.orderByCols = col
sb.orderByCols = append(sb.orderByCols, col...)
sb.marker = selectMarkerAfterOrderBy
return sb
}
Expand Down
1 change: 0 additions & 1 deletion struct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ func (db testDB) Query(query string, args ...interface{}) (testRows, error) {
}

func (db testDB) Exec(query string, args ...interface{}) {
return
}

func (rows testRows) Close() error {
Expand Down

0 comments on commit 0e6e16e

Please sign in to comment.