JQL (JQL v0.0.1)

View Source

JQL is an Elixir DSL for writing Atlassian Jira Query Language expressions.

Features

  • Compile-time validation of queries
  • Query composition
  • Syntax highlighting

Examples

Compound queries

iex> query = JQL.query(:status == "Done" and :created >= {:days, -5}, order_by: {:desc, :updated})
iex> to_string(query)
~S[status = Done and created >= -5d order by updated desc]

Query Composition

query = JQL.query(:status == "Done")

if created_after = opts[:created_after] do
  JQL.query(query, :created >= ^created_after)
else
  query
end

Summary

Functions

Concatenates two query expressions

DSL for expressing a JQL query as elixir terms

DSL for epxressing writing elixir terms with a trailing order_by

Allows for writing field was in (value1, value2) type expressions

Appends a JQL expression to an existing query

Functions

join(one, two)

Concatenates two query expressions

Queries will be joined together with an and expression

query(expression)

(macro)

DSL for expressing a JQL query as elixir terms

iex> jql = JQL.query(:project == "tvl" and Organizations in ["TV Labs", "ITV"])
iex> to_string(jql)
~S[project = tvl and Organizations in ("TV Labs", ITV)]

query(one, two)

(macro)

DSL for epxressing writing elixir terms with a trailing order_by

iex> jql = JQL.query(:project == "tvl", order_by: :created)
iex> to_string(jql)
~S[project = tvl order by created]

was_in(query, field, values)

(macro)

Allows for writing field was in (value1, value2) type expressions

where(query, expression)

(macro)

Appends a JQL expression to an existing query

iex> jql = JQL.query(:project == "tvl")
iex> to_string(JQL.where(jql, :status == "Done"))
~S[project = tvl and status = Done]

Order by supported too

iex> jql = JQL.query(:project == "tvl" and :status == "Done")
iex> to_string(JQL.where(jql, order_by: :created_at))
~S[project = tvl and status = Done order by created_at]