Fix find and count bug #1622
|
@ -903,7 +903,7 @@ func (statement *Statement) BuildConds(table *schemas.Table, bean interface{}, i
|
||||||
}
|
}
|
||||||
|
|
||||||
func (statement *Statement) mergeConds(bean interface{}) error {
|
func (statement *Statement) mergeConds(bean interface{}) error {
|
||||||
if !statement.NoAutoCondition {
|
if !statement.NoAutoCondition && statement.RefTable != nil {
|
||||||
var addedTableName = (len(statement.JoinStr) > 0)
|
var addedTableName = (len(statement.JoinStr) > 0)
|
||||||
autoCond, err := statement.BuildConds(statement.RefTable, bean, true, true, false, true, addedTableName)
|
autoCond, err := statement.BuildConds(statement.RefTable, bean, true, true, false, true, addedTableName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -519,10 +519,17 @@ func TestFindAndCountOneFunc(t *testing.T) {
|
||||||
|
|
||||||
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).FindAndCount(&results)
|
Limit(1).Cols("content").FindAndCount(&results)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, 1, len(results))
|
assert.EqualValues(t, 1, len(results))
|
||||||
assert.EqualValues(t, 1, cnt)
|
assert.EqualValues(t, 1, cnt)
|
||||||
|
|
||||||
|
ids := make([]int64, 0, 2)
|
||||||
|
tableName := testEngine.GetTableMapper().Obj2Table("FindAndCountStruct")
|
||||||
|
cnt, err = testEngine.Table(tableName).Limit(1).Cols("id").FindAndCount(&ids)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.EqualValues(t, 1, len(ids))
|
||||||
|
assert.EqualValues(t, 2, cnt)
|
||||||
}
|
}
|
||||||
|
|
||||||
type FindMapDevice struct {
|
type FindMapDevice struct {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user