问题
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