Skip to content

Commit a8d923a

Browse files
committed
prevent nil return when pairs iterates through empty space
Before this patch pairs returns "nil" if target space was empty. The reason is "has next" method of Iterator class that returns true before first get. This patch removes "has_next" call from lua generator function. Closes #82
1 parent 1efc3f8 commit a8d923a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1313
* Fixed select by part of sharding key equal. Before this patch
1414
selecting by equality of partially specified multipart primary index
1515
value was misinterpreted as a selecting by fully specified key value.
16+
* Fixed iteration with `pairs` through empty space returned `nil`.
1617

1718
### Added
1819

1920
* `truncate` operation
21+
* iterator returned by `pairs` is compatible with luafun
2022

2123
## [0.3.0] - 2020-10-26
2224

crud/select.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,11 @@ function select_module.pairs(space_name, user_conditions, opts)
223223
end
224224

225225
local gen = function(_, iter)
226-
if not iter:has_next() then
226+
local tuple, err = iter:get()
227+
if tuple == nil then
227228
return nil
228229
end
229230

230-
local tuple, err = iter:get()
231231
if err ~= nil then
232232
error(string.format("Failed to get next object: %s", err))
233233
end

0 commit comments

Comments
 (0)