diff --git a/session_find_test.go b/session_find_test.go index c215fd573..a8d14c0a2 100644 --- a/session_find_test.go +++ b/session_find_test.go @@ -8,6 +8,7 @@ import ( "errors" "fmt" "testing" + "time" "github.com/go-xorm/core" "github.com/stretchr/testify/assert" @@ -729,3 +730,40 @@ func TestFindExtends3(t *testing.T) { assert.NoError(t, err) assert.EqualValues(t, 2, len(results)) } + +func TestFindCacheLimit(t *testing.T) { + type InviteCode struct { + ID int64 `xorm:"pk autoincr 'id'"` + Code string `xorm:"unique"` + Created time.Time `xorm:"created"` + } + + assert.NoError(t, prepareEngine()) + assertSync(t, new(InviteCode)) + + cnt, err := testEngine.Insert(&InviteCode{ + Code: "123456", + }) + assert.NoError(t, err) + assert.EqualValues(t, 1, cnt) + + cnt, err = testEngine.Insert(&InviteCode{ + Code: "234567", + }) + assert.NoError(t, err) + assert.EqualValues(t, 1, cnt) + + for i := 0; i < 8; i++ { + var beans []InviteCode + err = testEngine.Limit(1, 0).Find(&beans) + assert.NoError(t, err) + assert.EqualValues(t, 1, len(beans)) + } + + for i := 0; i < 8; i++ { + var beans2 []*InviteCode + err = testEngine.Limit(1, 0).Find(&beans2) + assert.NoError(t, err) + assert.EqualValues(t, 1, len(beans2)) + } +} diff --git a/xorm.go b/xorm.go index b1032b526..d46370b65 100644 --- a/xorm.go +++ b/xorm.go @@ -17,7 +17,7 @@ import ( const ( // Version show the xorm's version - Version string = "0.6.6.0413" + Version string = "0.6.6.0429" ) func regDrvsNDialects() bool {