mardi 18 juin 2019

Checking for nils with luascript on redis calls is not working

I want to be able to check a value from a redis hash, date, to see if it is nil (in other words, the account is active)

local account = {}
local accountIds = redis.call('smembers', accounts)
for i, v in ipairs (accountIds)

    local accountDetails = redis.call('HMGET', 'accountHash' .. v, 'name', 'id', 'date')

    local date = accountDetails[3]

    if (date == nil) then
         table.insert(account, v)
         table.insert(account, list)
    end
end

When I print date on the java side while looping I get something like this:

2018-01-15 00:00:00.0, 2017-02-27 00:00:00.0, null, 2017-03-31 00:00:00.0, 2017-02-27 00:00:00.0, 2018-01-15 00:00:00.0, null,

So there are nils for date values, but my nil check is being skipped over every time. I have also tried:

if (date == 'nil') then
if (date == '') then
if (date == 'null') then
if (accountDetails[3] == nil) then
...

What am i doing wrong?

Aucun commentaire:

Enregistrer un commentaire