Skip to content

Commit

Permalink
add rawQuery function
Browse files Browse the repository at this point in the history
  • Loading branch information
devmoath committed Oct 30, 2021
1 parent ff4ccd8 commit 50b79c1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Expand Up @@ -61,6 +61,14 @@ generate query conditions based on your condition:
->getQuery(); // "project = 'MY PROJECT'"
```

generate query using raw query:

```php
\DevMoath\JqlBuilder\Jql::query()
->rawQuery("project = 'MY PROJECT' order by created asc")
->getQuery(); // "project = 'MY PROJECT' order by created asc"
```

Also, you can add macro functions as well:

```php
Expand Down
5 changes: 5 additions & 0 deletions src/Jql.php
Expand Up @@ -152,6 +152,11 @@ public function orderBy(string $column, string $direction): self
return tap($this, fn() => $this->appendQuery(self::ORDER_BY." $column $direction"));
}

public function rawQuery(string $query): self
{
return tap($this, fn() => $this->appendQuery($query));
}

public function getQuery(): string
{
return trim($this->query);
Expand Down
10 changes: 10 additions & 0 deletions tests/JqlTest.php
Expand Up @@ -64,6 +64,16 @@ public function it_can_generate_query_conditions_based_on_your_condition(): void
self::assertSame("project = 'MY PROJECT'", $query);
}

/** @test */
public function it_can_generate_query_using_raw_query(): void
{
$query = Jql::query()
->rawQuery("project = 'MY PROJECT' order by created asc")
->getQuery();

self::assertSame("project = 'MY PROJECT' order by created asc", $query);
}

/** @test */
public function it_can_add_macro(): void
{
Expand Down

0 comments on commit 50b79c1

Please sign in to comment.