如何处理在具有特殊字符的查询中使用的值? [英] How do I handle a value used in a query that has special characters?

查看:39
本文介绍了如何处理在具有特殊字符的查询中使用的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按迭代进行查询,但我们的迭代名称具有特殊字符(例如Sprint - 01 (Mar 26, 2012 to Apr 02, 2012)").

I'm trying to query by iteration but our iteration names have special characters (e.g. "Sprint - 01 (Mar 26, 2012 to Apr 02, 2012)").

无法解析从Sprint - 01(2012 年 3 月 26 日到 2012 年 4 月 2 日)"的对象引用"

Cannot parse object reference from "Sprint - 01 (Mar 26, 2012 to Apr 02, 2012)""

如果我在它周围添加括号(例如'(Iteration = ' + '\"Sprint - 01 (Mar 26, 2012 to Apr 02, 2012)\")'

If I add brackets around it all (e.g. '(Iteration = ' + '\"Sprint - 01 (Mar 26, 2012 to Apr 02, 2012)\")'

无法解析:未知运算符)"

Could not parse: Unknown operator ")"

如何正确处理带有这些字符的值?

How do I properly handle a value with these characters?

function itemQuery() {
  var queryObject = {
key: 'tasks',
type: 'task',
query: rally.sdk.util.Query.and(['State = "Completed"', 'TaskType = "Development"', 'Iteration = ' + '\"Sprint - 01 (Mar 26, 2012 to Apr 02, 2012)\"']),
fetch: 'FormattedID,Name,Owner,Estimate,Actuals'};

  rallyDataSource.findAll(queryObject, populateTable);
}

推荐答案

问题不在于特殊字符,而在于查询本身.当将 = 运算符用于迭代等对象时,它需要一个引用,例如 /iteration/1234.js.

The problem isn't the special characters but rather the query itself. When using the = operator for objects like iterations, it is expecting a ref, such as /iteration/1234.js.

相反,您可以通过迭代名称查询:

Instead, you can query via the iteration's name with:

...
query: rally.sdk.util.Query.and([
    'State = "Completed"', 
    'TaskType = "Development"', 
    'Iteration.Name = ' + '\"Sprint - 01 (Mar 26, 2012 to Apr 02, 2012)\"'
])
...  

不同的是迭代后加了.Name".由于名称在引号中,特殊字符已经可以毫无问题地进入网络服务.

The difference is the addition of ".Name" after iteration. Since the name is in quotations, the special characters can already make it into the web services without issue.

这篇关于如何处理在具有特殊字符的查询中使用的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆