yeahoffline / redis-mock

Node.js redis client mock
213 stars 111 forks source link

fixing the bug report - #152 #153

Closed kamiljano closed 3 years ago

kamiljano commented 3 years ago

fixing: https://github.com/yeahoffline/redis-mock/issues/152

isRyven commented 3 years ago

Thanks for looking into it, but better not to use or operator for this case, for instance these cases will return wrong result (null), while the values are being perfectly valid:

0 || null // null
"" || null // null

best way to check if key actually exists is using the in operator or object.hasOwnProperty(key):

if (mockInstance.storage[hash].value.hasOwnProperty(key)) {
    return mockInstance.storage[hash].value[key];
}
return null;
kamiljano commented 3 years ago

well that is a fair point. I'll fix it

kamiljano commented 3 years ago

et voilla