-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
[PostgreSQL] distinct() and inRandomOrder() issue #20457
Comments
Please share the Laravel code that lead to this query. |
I can try to submit PR for that, but later |
If it's not supported, why use it? |
It is not supported by PostgreSQL but supported by MySQL like issue found by me #19989 |
yes but Laravel doesn't use such query internally, so there's nothing we can change. Is there anywhere where Laravel uses distinct with inRandomOrder internally that you know of? |
No, Laravel not using this query internally, but it can break applications that depends on no database dependency of Eloquent after migration from MySQL to PostgreSQL. |
How can we fix it internally? If you run |
in inRandomOrder() make wrapper for it like that:
|
I don't believe we can force change the query like this, can't see anywhere in the source where we force change the structure of a query. Not all drivers support all types of queries, if the driver you picked doesn't support something I don't think there's anything we can do. Anyways if you have suggested change please feel free to open a PR, but I don't think restructuring the query into two queries like this can be easily done looking at how the query builder is structured. Closing this for now since it's not really a framework issue. But thanks for taking the time to answer my questions :) |
Description:
In PostgreSQL DISTINCT and ORDER BY RANDOM() can not be in one query
[Illuminate\Database\QueryException] SQLSTATE[42P10]: Invalid column reference: 7 ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
https://www.postgresql.org/message-id/[email protected]
The text was updated successfully, but these errors were encountered: