-
Notifications
You must be signed in to change notification settings - Fork 298
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
Initial support for JQL #721
base: master
Are you sure you want to change the base?
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 Field
s
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
Hello.
There is some basic support for JQL, could you suggest some impovements?
For now it produces
for a query like this