fix: numeric strings in mongo (#11498)

isekai-main
Barış Soner Uşaklı 2 years ago committed by GitHub
parent f8ae6ef7ef
commit 6bed65dde6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -49,15 +49,15 @@ module.exports = function (module) {
}
if (min !== '-inf') {
query.score = { $gte: min };
query.score = { $gte: parseFloat(min) };
}
if (max !== '+inf') {
query.score = query.score || {};
query.score.$lte = max;
query.score.$lte = parseFloat(max);
}
if (max === min) {
query.score = max;
query.score = parseFloat(max);
}
const fields = { _id: 0, _key: 0 };

@ -452,6 +452,12 @@ describe('Sorted Set methods', () => {
});
});
});
it('should return elements if min/max are numeric strings', async () => {
await db.sortedSetAdd('zsetstringminmax', [1, 2, 3, 4, 5], ['value1', 'value2', 'value3', 'value4', 'value5']);
const results = await db.getSortedSetRevRangeByScore('zsetstringminmax', 0, -1, '3', '3');
assert.deepStrictEqual(results, ['value3']);
});
});
describe('getSortedSetRevRangeByScore()', () => {

Loading…
Cancel
Save