Skip to content

Commit ac51a0f

Browse files
committed
fix: important bug with sorting when some of the values do not exist
1 parent 8ca66a0 commit ac51a0f

File tree

4 files changed

+523
-4
lines changed

4 files changed

+523
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "redis-filtered-sort",
3-
"version": "1.3.1",
3+
"version": "1.3.2",
44
"description": "Exports LUA script, which is able to perform multi filter operations, as well as sorts",
55
"main": "index.js",
66
"scripts": {

sorted-filtered-list.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ if rcall("EXISTS", PSSKey) == 0 then
148148
local arr = {};
149149
for i,v in pairs(valuesToSort) do
150150
local metaKey = metadataKey:gsub("*", v, 1);
151-
arr[v] = rcall("HGET", metaKey, hashKey);
151+
-- defaults to empty string to avoid sorting problems
152+
arr[v] = rcall("HGET", metaKey, hashKey) or '';
152153
end
153154

154155
local function sortFuncASC(a, b)

test/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
redis:
2-
image: redis:3.2.4-alpine
2+
image: redis:3.2.7-alpine
33
container_name: redis
44
hostname: redis
55
expose:
66
- "6379"
77

88
tester:
9-
image: makeomatic/node:6.5.0
9+
image: makeomatic/node:7.5.0
1010
links:
1111
- redis
1212
working_dir: /src

0 commit comments

Comments
 (0)