rally - 当存在两个以上 AND 子句时,多子句 AND 查询不起作用

标签 rally

我为我的公司创建了一个自定义应用程序,只要其中只有两个字段,查询就可以正常工作,一旦添加第三个字段,它就不会返回任何记录:

作为引用,我正在查询故事和缺陷:

    var query = [];
var queryCriteria = buildQueryFilter(STORIES);
query[0] = {
    key   : STORIES,
    type  : "HierarchicalRequirement",
    fetch : "FormattedID,Name,Owner,SubProject,CreationDate,Release,Iteration,ScheduleState,State,Build,Parent",
    order : "FormattedID",
    query : queryCriteria
};

var queryCriteria = buildQueryFilter(DEFECTS);
if (!(showUserStoriesOnly)){
    query[1] = {
        key   : DEFECTS,
        type  : "defects",
        fetch : "FormattedID,Name,Owner,SubProject,CreationDate,Release,Iteration,ScheduleState,State,FixedInBuild,Requirement",
        order : "FormattedID",
        query : queryCriteria
    };
}

rallyDataSource.findAll(query, showResults);

编辑:以下是 buildQueryFilter 的一些“缩写”代码:

returnFilter += returnFilter.length === 0 ? '' : ' AND '
returnFilter += '(Iteration.Name = "' + filterIteration + '")';

returnFilter += returnFilter.length === 0 ? '' : ' AND '
returnFilter += '(ScheduleState = "' + filterScheduleState + '")';

returnFilter += returnFilter.length === 0 ? '' : ' AND '
returnFilter += '(Owner = \"__USER_NAME__\")';


returnFilter = '(' + returnFilter + ')';                        

当“queryCriteria”为:

查询(故事):((Iteration.Name = "25 (10/02 - 10/16)") AND (ScheduleState = "Accepted"))

查询(缺陷):((Iteration.Name = "25 (10/02 - 10/16)") AND (ScheduleState = "Accepted"))

它有效。但是一旦我添加了第三字段 - 无论什么字段或什么顺序 - 那么它就不再起作用了:

查询(故事):((Iteration.Name = "25 (10/02 - 10/16)") AND (ScheduleState = "已接受") AND (Owner = "[email protected] “))

查询(缺陷):((Iteration.Name = "25 (10/02 - 10/16)") AND (ScheduleState = "Accepted") AND (Owner = "[email protected] “))

我一直在查看文档,这应该可行。我不知道为什么不是。有人知道吗?

谢谢!

最佳答案

使用rally.sdk.util.Query实用程序应该帮助您构建有效的查询(在大型查询中使用所有嵌套的 () 时,语法可能会变得非常难以阅读)。

var queries = [
    'Iteration.Name = "' + filterIteration + '"',
    'ScheduleState = "' + filterScheduleState + '",
    'Owner = "__USER_NAME__"'
];
var queryFilter = rally.sdk.util.Query.and(queries);
var queryString = queryFilter.toString();

//queryString should be this:
//(((Iteration.Name = "25 (10/02 - 10/16)") AND (ScheduleState = "Accepted")) AND (Owner = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e095938592a0848f8d81898ece838f8d" rel="noreferrer noopener nofollow">[email protected]</a>"))

关于rally - 当存在两个以上 AND 子句时,多子句 AND 查询不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13031325/

相关文章:

Rally:如何使用 REST API 将测试用例与用户故事进行映射?

javascript - 使用 JavaScript 查询投资组合项目时使用的正确 "Type"是什么

.net - 发布没有必填字段值的新缺陷时,Rally Rest .NET API 抛出 KeyNotFoundException

javascript - 如何在 Rally 中更改项目累积流程图的上下文?

testing - Rally 项目中每个测试集的详细 View

javascript - Rally App SDK 2.0/SharePoint 集成

java - 使用 Rally api v2.0,我在查询订阅对象时无法访问工作区列表

rally - 如何在集会用户故事页面上设置默认 View

java - 在 Java 中向 Rally 添加新用户

rally - 如何从工作区级别向版本添加自定义字段?