Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] set/reset the select to from.* in cloneForPaginationCount #32691

Closed
wants to merge 1 commit into from
Closed

[7.x] set/reset the select to from.* in cloneForPaginationCount #32691

wants to merge 1 commit into from

Conversation

patrickomeara
Copy link
Contributor

@patrickomeara patrickomeara commented May 6, 2020

In #32624 the pagination count query is now wrapped in a select count(*) as aggregate query for group by and havings, and the builder is used as a subquery.

If the builder has a join, but doesn't have a select, a duplicate column error is produced.

#32624 (comment)

This PR ensures the select is only from the primary table. As it is a subquery for a count, the columns in the subquery are irrelevant.

@patrickomeara patrickomeara changed the title set/reset the select to from.* set/reset the select to from.* in cloneForPaginationCount May 6, 2020
* wrapping a join with the same table column name produces a duplicate column error
@patrickomeara patrickomeara changed the title set/reset the select to from.* in cloneForPaginationCount [7.x] set/reset the select to from.* in cloneForPaginationCount May 6, 2020
@taylorotwell
Copy link
Member

This doesn't feel correct. This is mutating the original query instead of the cloned query.

@taylorotwell
Copy link
Member

Paste the exact Eloquent query from your actual code base showing how to trigger this.

@taylorotwell
Copy link
Member

Fixed this here: 98a242e

PauBenetPrat pushed a commit to PauBenetPrat/framework that referenced this pull request Mar 11, 2021
…gination.

This was added on this PR laravel#32691 at this specific commit:
laravel@98a242e

A part from that, there is no way to select null columns, always
receiving array(null) instead.

On the other hand, if we join tables and use select *, we could be using
diferent fields from each table but it always breaks when paginating because of
duplicate column name 'id'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants