-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
one-of-many relationship is not working if primary key is UUID (i.e Not Sortable). #37854
Comments
Heya, thanks for reporting. I'll need more info and/or code to debug this further. Can you please create a repository with the command below, commit the code that reproduces the issue and share the repository here? Please make sure that you have the latest version of the Laravel installer in order to run this command. Please also make sure you have both Git & the GitHub CLI tool properly set up. laravel new bug-report --github="--public" Please do not amend and create a separate commit with your custom changes. After you've posted the repository, I'll try to reproduce the issue. Thanks! Ping @cbl |
see: #37362 (comment)
|
@cbl I'm using Str::orderedUuid() only as a model UUID. |
@driesvints @cbl @taylorotwell |
Thanks @pushpak1300, that was helpful. @cbl it indeed doesn't seems to be possible to use one-of-many in combination with UUID's and PostgreSQL. PostgreSQL simply lacks support to calculate the max UUID. I've sent in a note to the docs to document this: laravel/docs#7170 @pushpak1300 there does seems to be a workaround by implementing a custom function: https://gist.github.com/devodo/8b39748d65e8185fbd89 |
Thanks, @driesvints |
I'm using "Advanced" method to fetch one-of-many (from Postgres with UUIDs).
@driesvints so I believe the only property that should be queried here is |
@nikans |
@cbl is there a way we can somehow override the max(id)? Like casting the unique key as string first before calling the function? max(id::text) |
Description:
It seems that the new One of Many relationships from #37362 does not work well when the primary key is UUID (i.e not sortable)
Steps To Reproduce:
When UUID is used for primary keys, fetching this relationship on the model I'm getting the following error.
The text was updated successfully, but these errors were encountered: