diff --git a/internal/sqladapter/result.go b/internal/sqladapter/result.go index 9070b9ef..6cc4bab6 100644 --- a/internal/sqladapter/result.go +++ b/internal/sqladapter/result.go @@ -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 { @@ -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...). diff --git a/internal/testsuite/sql_suite.go b/internal/testsuite/sql_suite.go index 80ad9d03..7a6fffbb 100644 --- a/internal/testsuite/sql_suite.go +++ b/internal/testsuite/sql_suite.go @@ -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) diff --git a/settings.go b/settings.go index 67449421..73f653ba 100644 --- a/settings.go +++ b/settings.go @@ -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,