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

Breaking change in query builder in v11.38 #54192

Closed
rikvdh opened this issue Jan 14, 2025 · 7 comments
Closed

Breaking change in query builder in v11.38 #54192

rikvdh opened this issue Jan 14, 2025 · 7 comments
Labels

Comments

@rikvdh
Copy link
Contributor

rikvdh commented Jan 14, 2025

Laravel Version

11.38.x

PHP Version

8.3.x

Database Driver & Version

No response

Description

@taylorotwell @GromNaN I can confirm that this: #53679 is breaking. Although you thought it was not.

With a having clause the ->min(...) makes the query itself a subquery making the grouped column 'unreadable'.

Steps To Reproduce

Query is an breaking example. My query has 3 joins and other conditions (but breaks in the same way).

Product::groupBy('products.id')->having('products.id', '>=', 12345)->min('products.id');

Image

@GromNaN
Copy link
Contributor

GromNaN commented Jan 14, 2025

I'm taking a look before it's reverted too quickly.

@crynobone crynobone added the bug label Jan 14, 2025
@GromNaN
Copy link
Contributor

GromNaN commented Jan 14, 2025

I tried to reproduce your issue but I get the same error with Laravel v11.37. The generated SQL query was already using the temp_table. You cannot prefix the column name with the table name in that case.

This query works

Product::groupBy('id')->having('id', '>=', 12345)->min('id');

@crynobone
Copy link
Member

@GromNaN It still shouldn't cause any breaking change. The PR should have targetted master branch if they introduce any breaking change.

@crynobone
Copy link
Member

Breaking changes reverted in 11.38.2

@GromNaN
Copy link
Contributor

GromNaN commented Jan 15, 2025

@crynobone this issue doesn't show any breaking change. The code sample was already not working before the PR you reverted.

@rikvdh
Copy link
Contributor Author

rikvdh commented Jan 15, 2025

@GromNaN I can come up with a way how this is breaking. It probably has to do with my select I had as well.

@rikvdh
Copy link
Contributor Author

rikvdh commented Jan 15, 2025

Sorry it was very difficult to come up with a 'minimal test'. As noted in the initial issue, the query is complex and I need to 'reduce' it to narrow it down to show the actual issue and make it understandable for everyone.

Product::groupBy('products.id')->having('products.id', '>=', 10002345)->selectRaw('products.id, products.modified as m')->min('m');

Image

I've verified that this works in v11.37.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants