Skip to content

Commit

Permalink
fix: reset $this->group_by
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Aug 9, 2023
1 parent 509266b commit 4e6486b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/CI3Compatible/Database/CI_DB_query_builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,7 @@ private function _reset_select()
$this->from = [];
$this->join = [];
$this->where = [];
$this->group_by = [];
$this->like = [];
$this->order_by = [];
}
Expand Down
14 changes: 14 additions & 0 deletions tests/CI3Compatible/Database/CI_DB_query_builderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,20 @@ public function test_group_by_multiple_calls(): void
$this->assertSame($expected, $sql);
}

public function test_group_by_multiple_queries(): void
{
$this->queryBuilder->group_by('title');
$this->queryBuilder->get('news');

$this->queryBuilder->get('news');

$db = $this->queryBuilder->getBaseConnection();
$sql = (string) $db->getLastQuery();
$expected = 'SELECT *
FROM `db_news`';
$this->assertSame($expected, $sql);
}

public function test_count_all(): void
{
$count = $this->queryBuilder->count_all('news');
Expand Down

0 comments on commit 4e6486b

Please sign in to comment.