From 8a7a8d48ad0e302d776114d449ba20a34d4904ba Mon Sep 17 00:00:00 2001 From: Harmen Date: Wed, 20 Jun 2018 14:06:31 +0200 Subject: [PATCH] fix lua nil for nested values Also for #43 --- integration/script_test.go | 2 ++ lua.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/integration/script_test.go b/integration/script_test.go index 58cabbc5..01984ffe 100644 --- a/integration/script_test.go +++ b/integration/script_test.go @@ -18,6 +18,8 @@ func TestEval(t *testing.T) { succ("EVAL", "return {ARGV[1]}", 0, "first\nwith\nnewlines!\r\r\n\t!"), succ("EVAL", "return redis.call('GET', 'nosuch')==false", 0), succ("EVAL", "return redis.call('GET', 'nosuch')==nil", 0), + succ("EVAL", "local a = redis.call('MGET', 'bar'); return a[1] == false", 0), + succ("EVAL", "local a = redis.call('MGET', 'bar'); return a[1] == nil", 0), // failure cases fail("EVAL"), diff --git a/lua.go b/lua.go index dbe6f0b8..5f0642f7 100644 --- a/lua.go +++ b/lua.go @@ -163,7 +163,7 @@ func redisToLua(l *lua.LState, res []interface{}) *lua.LTable { for _, e := range res { var v lua.LValue if e == nil { - v = lua.LValue(nil) + v = lua.LFalse } else { switch et := e.(type) { case int64: