From b2ff1594b8f14eb905ad50fe4d342e5cdc015c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 15 Oct 2020 22:25:56 -0400 Subject: [PATCH] fix: redis hget 'node_redis: The HGET command contains a invalid argument type.\n' + 'Only strings, dates and buffers are accepted. Please update your code to use valid argument types.' --- src/database/redis/hash.js | 2 +- test/database/hash.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/database/redis/hash.js b/src/database/redis/hash.js index d5636cdfe7..f615c989c5 100644 --- a/src/database/redis/hash.js +++ b/src/database/redis/hash.js @@ -75,7 +75,7 @@ module.exports = function (module) { if (cachedData[key]) { return cachedData[key].hasOwnProperty(field) ? cachedData[key][field] : null; } - return await module.client.async.hget(key, field); + return await module.client.async.hget(key, String(field)); }; module.getObjectFields = async function (key, fields) { diff --git a/test/database/hash.js b/test/database/hash.js index 8d94a23b6b..d3a5535d5d 100644 --- a/test/database/hash.js +++ b/test/database/hash.js @@ -211,6 +211,11 @@ describe('Hash methods', function () { done(); }); }); + + it('should return null and not error', async () => { + const data = await db.getObjectField('hashTestObject', ['field1', 'field2']); + assert.strictEqual(data, null); + }); }); describe('getObjectFields()', function () {