Skip to content

Commit

Permalink
fix #565
Browse files Browse the repository at this point in the history
  • Loading branch information
xiam committed May 19, 2020
1 parent 02d4f94 commit c2bd333
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions internal/sqladapter/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func NewResult(builder sqlbuilder.SQLBuilder, table string, conds []interface{})
}

func (r *Result) frame(fn func(*result) error) *Result {
return &Result{prev: r, fn: fn}
return &Result{err: r.err, prev: r, fn: fn}
}

func (r *Result) SQLBuilder() sqlbuilder.SQLBuilder {
Expand Down Expand Up @@ -400,8 +400,9 @@ func (r *Result) buildPaginator() (sqlbuilder.Paginator, error) {
return nil, err
}

sel := r.SQLBuilder().Select(res.fields...).
From(res.table).
b := r.SQLBuilder()

sel := b.Select(res.fields...).From(res.table).
Limit(res.limit).
Offset(res.offset).
GroupBy(res.groupBy...).
Expand Down
5 changes: 2 additions & 3 deletions internal/testsuite/sql_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -1928,15 +1928,14 @@ func (s *SQLTestSuite) TestCustomType() {
s.Equal("foo: some name", string(bar.Custom.Val))
}

func (s *SQLTestSuite) TestIssue565() {
func (s *SQLTestSuite) Test_Issue565() {
sess := s.Session().(sqlbuilder.Database)

ctx, _ := context.WithTimeout(context.Background(), time.Nanosecond)

sess = sess.WithContext(ctx)

var result birthday
err := sess.Collection("birthdays").Find().One(&result)
err := sess.Collection("birthdays").Find().Select("name").One(&result)

s.Error(err)
s.Zero(result.Name)
Expand Down
1 change: 1 addition & 0 deletions settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ func (c *settings) MaxOpenConns() int {
func NewSettings() Settings {
def := DefaultSettings.(*settings)
return &settings{
loggingEnabled: def.loggingEnabled,
preparedStatementCacheEnabled: def.preparedStatementCacheEnabled,
connMaxLifetime: def.connMaxLifetime,
maxIdleConns: def.maxIdleConns,
Expand Down

0 comments on commit c2bd333

Please sign in to comment.