mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 18:16:17 +01:00
feat: add null tests for sorted sets
This commit is contained in:
@@ -69,7 +69,8 @@ DO UPDATE SET "score" = EXCLUDED."score"`,
|
||||
return;
|
||||
}
|
||||
const isArrayOfScores = Array.isArray(scores);
|
||||
if (!isArrayOfScores && !utils.isNumber(scores)) {
|
||||
if ((!isArrayOfScores && !utils.isNumber(scores)) ||
|
||||
(isArrayOfScores && scores.map(s => utils.isNumber(s)).includes(false))) {
|
||||
throw new Error('[[error:invalid-score, ' + scores + ']]');
|
||||
}
|
||||
|
||||
@@ -108,6 +109,9 @@ INSERT INTO "legacy_zset" ("_key", "value", "score")
|
||||
const values = [];
|
||||
const scores = [];
|
||||
data.forEach(function (item) {
|
||||
if (!utils.isNumber(item[1])) {
|
||||
throw new Error('[[error:invalid-score, ' + item[1] + ']]');
|
||||
}
|
||||
keys.push(item[0]);
|
||||
scores.push(item[1]);
|
||||
values.push(item[2]);
|
||||
|
||||
Reference in New Issue
Block a user