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
{{ message }}
Repository navigation
Search and sort by localized field does not work: Error: Alias "XXX_locales" is already used in this query #7015
I have a posts collection with a localizedtitle field. In the Admin panel, I want to filter by the title. It works if the sortby is unset (it will sort by posts.id I think). If I sort by the title, the error occurs:
Error: Alias "posts_locales" is already used in this query
Reproduction Steps
Create a posts collection with a localizedtitle field
go to /admin/collections/posts
create a post record
enter to the search text input to filter by "title"
changed the title [-]Search and sort by localized field does not work[/-][+]Search and sort by localized field does not work: Error: Alias "XXX_locales" is already used in this query[/+]on Jul 3, 2024
Activity
[-]Search and sort by localized field does not work[/-][+]Search and sort by localized field does not work: Error: Alias "XXX_locales" is already used in this query[/+]lazidoca commentedon Jul 3, 2024
It seems like when there are multiple joins on the the same table, the
chainedMethodsis pushed with a new left join which causes the issue:https://github.com/payloadcms/payload/blob/93bdc0e98d5541fddfe5a143e5678164692d3d37/packages/db-postgres/src/queries/selectDistinct.ts#L37C1-L43C1
lazidoca commentedon Jul 3, 2024
Payload 3.0 beta 56 works fine, so I think the recent changes in beta 57 causes the issue
rainer-friederich commentedon Aug 16, 2024
Just wanted to add here that this is still an issue. We have this on the image collection when we search there.
In our image collection the alt and caption fields are localized and the search field then yields an error:
admin/collections/image?limit=10&page=1&search=testYields
This is because we have the alt and caption in the listSearchableFields:
If i remove alt and caption from there it works but only searches in the filename.
Update: This also works if i only remove the caption from the
listSearchableFields. So the "alt" somehow works.tiago-meireles commentedon Aug 30, 2024
I'm also having this issue.
This is the error message that appears
r1tsuu commentedon Sep 24, 2024
Fixed in #8396
fix(drizzle): use alias for localized field sorting (#8396)
github-actions commentedon Sep 26, 2024
This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.
github-actions commentedon Sep 26, 2024
🚀 This is included in version v3.0.0-beta.109