You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PDOException: SQLSTATE[42803]: Grouping error: 7ERROR: column "my_model.published_at" must appear in the GROUPBY clause or be used in an aggregate function...
@mhz-tamb, I looked into it a little more.
For Phalcon\Paginator\Adapter\QueryBuilder, as you pointed out, here has been taken care of.
But for Phalcon\Paginator\Adapter\Model, it just calls the model's count method like this.
let rowCountResult = call_user_func([modelClass, "count"], parameters);
In the model's count method, COUNT(*) AS rowcount is set as a column, and other parameters are also set unconditionally.
In a paginator, it is common for a sort order to be specified, so there is an order section in the parameters.
Then, the ORDER BY clause is added to COUNT() even though it is unnecessary.
From this, it is considered an obvious mistake to set all the parameters given when Model::count() is called.
The order section should be removed.
This is a bug.
Questions? Forum: https://phalcon.io/forum or Discord: https://phalcon.io/discord
Describe the bug
Phalcon\Paginator\Adapter\Model generates an invalid query with order parameter and postgres query execution fails.
The result query:
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The resulting query should not contain order parameters and should look like:
Apparently a similar problem is solved here:
https://github.com/phalcon/cphalcon/blob/5.0.x/phalcon/Paginator/Adapter/QueryBuilder.zep#L211
Details
The text was updated successfully, but these errors were encountered: