-
Notifications
You must be signed in to change notification settings - Fork 316
Initial support for JQL #721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
By JQL do you mean the selection in Jira or does it have more meanings? |
|
Could you add tests? |
I din't aim for full support, just the tools I use myself. |
|
I believe there is no need to start with full support. We can start little and then later extend it. Could you also add this possibility in the documentation? |
|
Sure! Done. |
docs/3_advanced.rst
Outdated
|
|
||
| .. code-block:: python | ||
| from pypika import MySQLQuery, MSSQLQuery, PostgreSQLQuery, OracleQuery, VerticaQuery |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JiraTable seems not to be imported and these seem unnecessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh
sorry, copypaste issue
|
ugh |
docs/3_advanced.rst
Outdated
|
|
||
| .. code-block:: python | ||
| from pypika import JiraTable, JiraQueryBuilder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the example use JiraQuery instead of JiraQueryBuilder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think that that would provide consistency with the rest of the API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest I just don't know how to make in consistent.
There are no such thing as tables (so JiraTable is just a dummy placeholder).
Best thing I can do is probably create a bunch of overrides for from_, into and other methods which would return cls._builder(**kwargs)
Is it ok?
>>> table = JiraTable()
>>> JiraQuery._builder().where(table.project.isin(["PROJ1", "PROJ2"]))
project IN ("PROJ1","PROJ2")There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. I guess JiraQuery.from_(table).where(table.project.isin(["PROJ1", "PROJ2"])) looks kind consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the JiraQuery could have a where class method as well that initializes table.
Personally, I tend to used Fields
Maybe it would read like this
query = (
JiraQuery
.where(
(Field("project").isin(["PROJ1", "PROJ2"]))
& (Field("issuetype") == "my_issue_type")
)
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Working in both ways:
>>> JiraQuery.where(Field("project").isin(["PROJ1", "PROJ2"]) & (Field("issuetype") == "my_issue_type"))
project IN ("PROJ1","PROJ2") AND issuetype="my_issue_type"
>>> table = JiraTable()
>>> JiraQuery.where(table.project.isin(["PROJ1", "PROJ2"]) | table.project == 2)
project IN ("PROJ1","PROJ2") OR project=2
docs/3_advanced.rst
Outdated
| J = JiraTable() | ||
| j = ( | ||
| JiraQuery._builder().from_(J) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend against using the _ methods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Just one more comment on the example
docs/3_advanced.rst
Outdated
| .where(J.labels.isempty() | J.labels.notin(["stale", "bug"])) | ||
| .where(J.repos.notempty() & J.repos.notin(["main", "dev"])) | ||
| ) | ||
| print(j.get_sql()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of the other examples show the result explicitly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Also I forgot to import JiraQuery into main class. So I also had to add Table method for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it looks good. Let's start to support JQL
# By Ashaya Sharma (1) and others # Via GitHub * upstream/master: Initial support for JQL (kayak#721) Add bitwiseor support and class (kayak#825) Add qualify (kayak#841) Signed-off-by: Akhil Narang <[email protected]> # Conflicts: # pypika/dialects.py
Hello.
There is some basic support for JQL, could you suggest some impovements?
For now it produces
for a query like this