Skip to content

Commit 0e0dd99

Browse files
authored
Merge pull request #196 from kuzzleio/msbugfix
Fix ms.hgetall return value interpretation
2 parents a013a74 + 56e7ee7 commit 0e0dd99

File tree

2 files changed

+2
-27
lines changed

2 files changed

+2
-27
lines changed

src/MemoryStorage.js

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ var
6565
hdel: {required: ['_id', 'fields']},
6666
hexists: getIdField,
6767
hget: getIdField,
68-
hgetall: {getter: true, required: ['_id'], mapResults: mapKeyValueResults},
68+
hgetall: {getter: true, required: ['_id']},
6969
hincrby: setIdFieldValue,
7070
hincrbyfloat: {required: ['_id', 'field', 'value'], mapResults: parseFloat},
7171
hkeys: getId,
@@ -453,31 +453,6 @@ function mapArrayStringToArrayInt(results) {
453453
});
454454
}
455455

456-
/**
457-
* Map results like ['key', 'value', 'key', 'value', ...]
458-
* to a JSON object {key: 'value', ...}
459-
*
460-
* @param {Array.<string>} results
461-
* @return {Object}
462-
*/
463-
function mapKeyValueResults(results) {
464-
var
465-
buffer = null,
466-
mapped = {};
467-
468-
results.forEach(function (value) {
469-
if (buffer === null) {
470-
buffer = value;
471-
}
472-
else {
473-
mapped[buffer] = value;
474-
buffer = null;
475-
}
476-
});
477-
478-
return mapped;
479-
}
480-
481456
/**
482457
* Map zrange results with WITHSCORES:
483458
* [

test/MemoryStorage/methods.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ describe('MemoryStorage methods', function () {
407407
{},
408408
{_id: 'key'},
409409
{},
410-
['foo', 'bar', 'baz', 'qux'],
410+
{foo: 'bar', baz: 'qux'},
411411
{foo: 'bar', baz: 'qux'}
412412
);
413413
});

0 commit comments

Comments
 (0)