mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-23 19:43:09 +00:00
修复 mongo 游标没有数据 hasNext 返回 true,以及无效关闭游标的问题 (#1653)
Co-authored-by: yy151474 <yy151474@alibaba-inc.com>
This commit is contained in:
@@ -79,11 +79,20 @@ function test_find_and_remove()
|
||||
db.testcoll:dropIndex("*")
|
||||
db.testcoll:drop()
|
||||
|
||||
local cursor = db.testcoll:find()
|
||||
assert(cursor:hasNext() == false)
|
||||
|
||||
db.testcoll:ensureIndex({test_key = 1}, {test_key2 = -1}, {unique = true, name = "test_index"})
|
||||
|
||||
ok, err, ret = db.testcoll:safe_insert({test_key = 1, test_key2 = 1})
|
||||
assert(ok and ret and ret.n == 1, err)
|
||||
|
||||
cursor = db.testcoll:find()
|
||||
assert(cursor:hasNext() == true)
|
||||
local v = cursor:next()
|
||||
assert(v)
|
||||
assert(v.test_key == 1)
|
||||
|
||||
ok, err, ret = db.testcoll:safe_insert({test_key = 1, test_key2 = 2})
|
||||
assert(ok and ret and ret.n == 1, err)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user