How do I handle a value used in a query that has special characters?

自古美人都是妖i 提交于 2019-12-11 04:58:22

问题


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)").

Cannot parse object reference from "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);
}

回答1:


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)\"'
])
...  

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.



来源:https://stackoverflow.com/questions/9879339/how-do-i-handle-a-value-used-in-a-query-that-has-special-characters

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!