Skip to content

Commit

Permalink
fix: redis hget
Browse files Browse the repository at this point in the history
'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.'
  • Loading branch information
barisusakli committed Oct 16, 2020
1 parent e98285d commit b2ff159
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/database/redis/hash.js
Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions test/database/hash.js
Expand Up @@ -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 () {
Expand Down

0 comments on commit b2ff159

Please sign in to comment.