fix findandcount bug (#853)
This commit is contained in:
parent
a4378c8abd
commit
17ee4be6c1
|
@ -52,6 +52,10 @@ func (session *Session) FindAndCount(rowsSlicePtr interface{}, condiBean ...inte
|
|||
}
|
||||
session.autoResetStatement = true
|
||||
|
||||
if session.statement.selectStr != "" {
|
||||
session.statement.selectStr = ""
|
||||
}
|
||||
|
||||
return session.Count(reflect.New(sliceElementType).Interface())
|
||||
}
|
||||
|
||||
|
|
|
@ -561,4 +561,11 @@ func TestFindAndCountOneFunc(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 1, len(results))
|
||||
assert.EqualValues(t, 1, cnt)
|
||||
|
||||
results = make([]FindAndCountStruct, 0, 1)
|
||||
cnt, err = testEngine.Where("msg = ?", true).Select("id, content, msg").
|
||||
Limit(1).FindAndCount(&results)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 1, len(results))
|
||||
assert.EqualValues(t, 1, cnt)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue