Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@doc-sheet
Copy link
Contributor

Hello.

There is some basic support for JQL, could you suggest some impovements?

For now it produces

project IN ("PROJ1","PROJ2") AND issuetype="My issue" AND (labels is EMPTY OR labels NOT IN ("stale","bug")) AND Привет is EMPTY AND repos is not EMPTY AND repos NOT IN ("main","dev")

for a query like this

J = JiraTable()
j = (
    JiraQueryBuilder()
    .where(J.project.isin(["PROJ1", "PROJ2"]))
    .where(J.issuetype == "My issue")
    .where(J.labels.isempty() | J.labels.notin(["stale", "bug"]))
    .where(getattr(J, "Привет").isempty())
    .where(J.repos.notempty() & J.repos.notin(["main", "dev"]))
)
print(j.get_sql())

@doc-sheet doc-sheet requested a review from a team as a code owner March 25, 2023 15:22
@AzisK
Copy link
Contributor

AzisK commented Sep 22, 2023

By JQL do you mean the selection in Jira or does it have more meanings?

@AzisK
Copy link
Contributor

AzisK commented Sep 22, 2023

Could you add tests?

@doc-sheet
Copy link
Contributor Author

By JQL do you mean the selection in Jira or does it have more meanings?
Yeah, jql as jira query language

I din't aim for full support, just the tools I use myself.
But I can add more if needed. I guess.

@AzisK
Copy link
Contributor

AzisK commented Sep 24, 2023

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?

@doc-sheet
Copy link
Contributor Author

Sure! Done.


.. code-block:: python
from pypika import MySQLQuery, MSSQLQuery, PostgreSQLQuery, OracleQuery, VerticaQuery
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh
sorry, copypaste issue

@doc-sheet
Copy link
Contributor Author

ugh
There was a dependency conflict in my venv: https://stackoverflow.com/a/71674345


.. code-block:: python
from pypika import JiraTable, JiraQueryBuilder
Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

@williambdean williambdean Oct 17, 2023

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

Copy link
Contributor Author

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

J = JiraTable()
j = (
JiraQuery._builder().from_(J)
Copy link
Contributor

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

Copy link
Contributor

@williambdean williambdean left a 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

.where(J.labels.isempty() | J.labels.notin(["stale", "bug"]))
.where(J.repos.notempty() & J.repos.notin(["main", "dev"]))
)
print(j.get_sql())
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

@AzisK AzisK left a 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

@AzisK AzisK merged commit d9f5b52 into kayak:master Sep 23, 2025
6 checks passed
@coveralls
Copy link

Coverage Status

coverage: 98.374% (-0.04%) from 98.411%
when pulling fa56f4c on doc-sheet:jql_init
into 89c1ef0 on kayak:master.

akhilnarang added a commit to frappe/pypika that referenced this pull request Sep 29, 2025
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants