-
-
Notifications
You must be signed in to change notification settings - Fork 156
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
Multiple orderByTranslation() brings sql ERROR: Duplicate alias #193
Comments
You can select raw
then you can alias the joins
then maybe / probably (unsure about using alias here)
|
Thanks. But i was thinking about to check, in scopeOrderByTranslation function, if table is already joined in Laravel Query Builder, then without leftJoin second time, make only orderBy.
|
Hey, thanks for the working example @igor-rastorguev . I'm still unsure about it as it feels somehow hacky. 🤔 |
When i do multiple sort on localized columns name and full_name with orderByTranslation, I get SQL error.
SQLSTATE[42712]: Duplicate alias: 7 ERROR: table name "manufacturer_translations" specified more than once (SQL: select "manufacturers".* from "manufacturers" left join "manufacturer_translations" on "manufacturer_translations"."manufacturer_id" = "manufacturers"."id" and "manufacturer_translations"."locale" = ru left join "manufacturer_translations" on "manufacturer_translations"."manufacturer_id" = "manufacturers"."id" and "manufacturer_translations"."locale" = ru where "manufacturers"."deleted_at" is null order by "manufacturer_translations"."name" asc, "manufacturer_translations"."full_name" asc limit 51 offset 0)
How i can avoid this problem?
The text was updated successfully, but these errors were encountered: