Fix find and count bug with cols (#1826)
Fix find and count bug with cols Reviewed-on: https://gitea.com/xorm/xorm/pulls/1826 Co-Authored-By: Lunny Xiao <xiaolunwen@gmail.com> Co-Committed-By: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
beac298c02
commit
acb337ba1f
|
@ -552,6 +552,13 @@ func TestFindAndCountOneFunc(t *testing.T) {
|
||||||
assert.EqualValues(t, 1, len(results))
|
assert.EqualValues(t, 1, len(results))
|
||||||
assert.EqualValues(t, 1, cnt)
|
assert.EqualValues(t, 1, cnt)
|
||||||
|
|
||||||
|
results = make([]FindAndCountStruct, 0, 1)
|
||||||
|
cnt, err = testEngine.Where("msg = ?", true).Cols("id", "content", "msg").
|
||||||
|
Limit(1).FindAndCount(&results)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.EqualValues(t, 1, len(results))
|
||||||
|
assert.EqualValues(t, 1, cnt)
|
||||||
|
|
||||||
results = make([]FindAndCountStruct, 0, 1)
|
results = make([]FindAndCountStruct, 0, 1)
|
||||||
cnt, err = testEngine.Where("msg = ?", true).Desc("id").
|
cnt, err = testEngine.Where("msg = ?", true).Desc("id").
|
||||||
Limit(1).Cols("content").FindAndCount(&results)
|
Limit(1).Cols("content").FindAndCount(&results)
|
||||||
|
|
|
@ -57,6 +57,9 @@ func (session *Session) FindAndCount(rowsSlicePtr interface{}, condiBean ...inte
|
||||||
if session.statement.SelectStr != "" {
|
if session.statement.SelectStr != "" {
|
||||||
session.statement.SelectStr = ""
|
session.statement.SelectStr = ""
|
||||||
}
|
}
|
||||||
|
if len(session.statement.ColumnMap) > 0 {
|
||||||
|
session.statement.ColumnMap = []string{}
|
||||||
|
}
|
||||||
if session.statement.OrderStr != "" {
|
if session.statement.OrderStr != "" {
|
||||||
session.statement.OrderStr = ""
|
session.statement.OrderStr = ""
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue