WL JSONStore 排序键 <field> 不是有效字符串之一
WL JSONStore Sort key <field> is not one of the valid strings
我在尝试对 findAll 进行排序时遇到错误:
"Sort key dateis not one of the valid strings."
我的选择如下(我尝试了不同的 desc 格式,每个人都抛出相同的 'error'):
var options = {sort: [{"date": "desc"}]};
一切似乎都很好,JSONStore 按预期工作,对 returned 数据进行排序,我只是想确定 'error' 确实是 [=32= 上的错误或错误] 部分并不是我做错了什么。
这是在 worklight.js:
中检查有效 sortObj 的函数
/** Checks if sortObj is a valid sort object for a query
* @private
*/
var __isValidSortObject = function(sortObj, searchFields, additionalSearchFields) {
var propertiesValidated = 0,
sortObjKey, sortStr;
for (sortObjKey in sortObj) {
if (sortObj.hasOwnProperty(sortObjKey)) {
if (propertiesValidated > 0) {
WL.Logger.trace('Sort object ' + JSON.stringify(sortObj) + ' has more than one property. Each object must have only one property.');
return false;
}
//check is sortObjKey is lowerCase
if (_.isUndefined(searchFields[sortObjKey.toLowerCase()]) && _.isUndefined(additionalSearchFields[sortObjKey.toLowerCase()])) {
WL.Logger.trace('Sort key ' + sortObjKey + ' is not part of search fields: ' + JSON.stringify(searchFields) + ' or additional search fields: ' + JSON.stringify(additionalSearchFields));
return false;
}
sortStr = sortObj[sortObjKey];
//Check that the string that specifies sorting order says either "asc" or "desc"
**if (__isString(sortStr) && sortStr.length > 0 && (/^(a|de)sc$/i.test(sortStr))) {
WL.Logger.trace('Sort key ' + sortObjKey + 'is not one of the valid strings.');
propertiesValidated++;
} else {
// Here seems to be the problem, shouldn't the trace be before return false?
return false;
}**
}
}
if (propertiesValidated === 0) {
return false;
}
return true;
};
您可以清楚地看到他们在检查正常时执行 WL.Logger.trace,并且应该在 return false 之前。
是否有人在 JSONStore 上使用过排序也收到此跟踪?
平台版本:7.1.0.00.20160129-1923
我联系了 IBM 支持,他们确实确认这是一个将在下一个版本中解决的错误。
我在尝试对 findAll 进行排序时遇到错误:
"Sort key dateis not one of the valid strings."
我的选择如下(我尝试了不同的 desc 格式,每个人都抛出相同的 'error'):
var options = {sort: [{"date": "desc"}]};
一切似乎都很好,JSONStore 按预期工作,对 returned 数据进行排序,我只是想确定 'error' 确实是 [=32= 上的错误或错误] 部分并不是我做错了什么。
这是在 worklight.js:
中检查有效 sortObj 的函数 /** Checks if sortObj is a valid sort object for a query
* @private
*/
var __isValidSortObject = function(sortObj, searchFields, additionalSearchFields) {
var propertiesValidated = 0,
sortObjKey, sortStr;
for (sortObjKey in sortObj) {
if (sortObj.hasOwnProperty(sortObjKey)) {
if (propertiesValidated > 0) {
WL.Logger.trace('Sort object ' + JSON.stringify(sortObj) + ' has more than one property. Each object must have only one property.');
return false;
}
//check is sortObjKey is lowerCase
if (_.isUndefined(searchFields[sortObjKey.toLowerCase()]) && _.isUndefined(additionalSearchFields[sortObjKey.toLowerCase()])) {
WL.Logger.trace('Sort key ' + sortObjKey + ' is not part of search fields: ' + JSON.stringify(searchFields) + ' or additional search fields: ' + JSON.stringify(additionalSearchFields));
return false;
}
sortStr = sortObj[sortObjKey];
//Check that the string that specifies sorting order says either "asc" or "desc"
**if (__isString(sortStr) && sortStr.length > 0 && (/^(a|de)sc$/i.test(sortStr))) {
WL.Logger.trace('Sort key ' + sortObjKey + 'is not one of the valid strings.');
propertiesValidated++;
} else {
// Here seems to be the problem, shouldn't the trace be before return false?
return false;
}**
}
}
if (propertiesValidated === 0) {
return false;
}
return true;
};
您可以清楚地看到他们在检查正常时执行 WL.Logger.trace,并且应该在 return false 之前。
是否有人在 JSONStore 上使用过排序也收到此跟踪?
平台版本:7.1.0.00.20160129-1923
我联系了 IBM 支持,他们确实确认这是一个将在下一个版本中解决的错误。