good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit 0f7146ac authored by José Nieto's avatar José Nieto Committed by GitHub
Browse files

Merge pull request #620 from upper/issue-616_add-limit-to-one

Set "LIMIT 1" when using One()
parents bc21d72e d3f71bb2
No related branches found
No related tags found
No related merge requests found
......@@ -234,7 +234,8 @@ func (r *Result) All(dst interface{}) error {
// One fetches only one Result from the set.
func (r *Result) One(dst interface{}) error {
query, err := r.buildPaginator()
one := r.Limit(1).(*Result)
query, err := one.buildPaginator()
if err != nil {
r.setErr(err)
return err
......
......@@ -124,7 +124,7 @@ func (s *SQLTestSuite) TestPreparedStatementsCache() {
// This query is different on each iteration and generates a new
// prepared statement everytime it's called.
res := sess.Collection("artist").Find().Select(db.Raw(fmt.Sprintf("count(%d)", i)))
res := sess.Collection("artist").Find().Select(db.Raw(fmt.Sprintf("count(%d) AS c", i)))
var count map[string]uint64
err := res.One(&count)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment