Skip to content

Wrong record count in DataProvider when using JoinWith in Search #15025

@OceanWind

Description

@OceanWind

What steps will reproduce the problem?

In the ModelSearch class, include a JoinWith parameter in the initial find statement. For example:

$query = Quote::find() ->joinWith(['author','source','themes']);

What is the expected result?

The number of records displayed at the beginning of GridView (or when grabbing $dataProvider->getTotalCount()) should be accurate.

If I remove the JoinWith statement, the GridView summary displays:

Showing 1-20 of 4,400 items.

What do you get instead?

In my case, it calculates there are almost 2000 more records than actually exist. Plus it changed the number per page:

Showing 1-15 of 6,242 items.

Please note that all that changed was that I removed the JoinWith statement.

Additional info

Q A
Yii version 2.0.12
PHP version 5.6.31
Operating system Linux 2.6.32-696.3.1.el6.x86_64 #1 SMP Tue May 30 19:52:55 UTC 2017

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions