dapplo / Dapplo.Jira

This is a simple REST based JIRA client, written for Greenshot, by using Dapplo.HttpExtension
MIT License
35 stars 14 forks source link

Bad Request response due to Invalid JQL #44

Closed rburnham52 closed 4 years ago

rburnham52 commented 4 years ago

I'm not sure if i'm creating my query correctly but i am receiving the following error once i added the Or condition

{"errorMessages":["Error in the JQL Query: 'End' is a reserved JQL word. You must surround it in quotation marks to use it in a query. (line 1, character 108)"],"errors":{}}

   var jql = Where.And(
                Where.Project.Is(project),
                Where.Type.In(project.IssueTypes.Where(t => issueTypes.Contains(t.Name)).ToArray()),
                Where.Or(
                    Where.And(
                        Where.Resolved.AfterOrOn.DateTime(startDate),
                        Where.Resolved.BeforeOrOn.DateTime(endDate ?? DateTime.Now)
                    ),
                    Where.Status.Is("End to End Testing")
                )
            );

However when i remove the Or condition it works

            var jql = Where.And(
                Where.Project.Is(project),
                Where.Type.In(project.IssueTypes.Where(t => issueTypes.Contains(t.Name)).ToArray()),
                Where.Resolved.AfterOrOn.DateTime(startDate),
                Where.Resolved.BeforeOrOn.DateTime(endDate ?? DateTime.Now)
            );
Lakritzator commented 4 years ago

Hi,

The issue is the "End to End Testing".

I will need to add quotation marks (escaping) in the generated query to make sure that values you supply don't cause an error in the query.

I'll try to free up some time to look at it, but with having a kid and the corona virus forced all kindergarten to close... it will depend on how tough it is to fix.

You are also welcome to create a pull request, if you think you can fix it yourself. But I might need a generic solution, not only for Status.Is but all other options too.

Best wishes, Robin

Lakritzator commented 4 years ago

I made a fix for your issue, I couldn't find any other pressing issues so I only made a small change.

Let me know if version 0.9.21 works for you!

rburnham52 commented 4 years ago

@Lakritzator thanks for the quick response. that looked like it fixed the issue