mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 13:02:24 +08:00
Fix #20226: Revert all PR for "Data providers perform unnecessary COUNT queries that negatively affect performance"
This commit is contained in:
@ -170,8 +170,9 @@ abstract class ActiveDataProviderTest extends DatabaseTestCase
|
||||
'query' => $query->from('order')->orderBy('id'),
|
||||
]);
|
||||
$pagination = $provider->getPagination();
|
||||
$this->assertEquals(1, $pagination->getPageCount());
|
||||
$this->assertEquals(0, $pagination->getPageCount());
|
||||
$this->assertCount(3, $provider->getModels());
|
||||
$this->assertEquals(1, $pagination->getPageCount());
|
||||
|
||||
$provider->getPagination()->pageSize = 2;
|
||||
$this->assertCount(3, $provider->getModels());
|
||||
@ -197,23 +198,4 @@ abstract class ActiveDataProviderTest extends DatabaseTestCase
|
||||
|
||||
$this->assertEquals(0, $pagination->getPageCount());
|
||||
}
|
||||
|
||||
public function testTotalCountAfterSearch()
|
||||
{
|
||||
$query = Order::find();
|
||||
$provider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
'pagination' => [
|
||||
'pageSize' => 2,
|
||||
],
|
||||
]);
|
||||
|
||||
$pagination = $provider->getPagination();
|
||||
$this->assertEquals(2, $pagination->getPageCount());
|
||||
$this->assertEquals(3, $pagination->getTotalCount());
|
||||
|
||||
$query->andWhere(['customer_id' => 2]);
|
||||
$this->assertEquals(1, $pagination->getPageCount());
|
||||
$this->assertEquals(2, $pagination->getTotalCount());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user