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
Preview feature feedback: Order By Nulls (orderByNulls
)
#14377
Comments
orderByNulls
)
Hi there, I really like the orderByNulls functionality. Yet, there is one thing I can't get working. I'd like to display nulls as last, but without having to sort the non-null values. I am trying to sort users based on information being present, but I am using other filters aswell. e.g.: sorting users on ID desc and displaying user without a profile picture last. Any idea on how to use this feature to get to the desired result? |
I like this feature, but I'd like to request the behavior of generated types changes a little if possible. If I have a model such as
And I set the order by in a findMany for example as
This currently results in an error whereas if I sort by
It's nice to be able to pass this as a no op for the purposes of developing an api against a dataset using this feature. I want that api to have null order parameters where I can use this feature, but I now have to ensure that I'm only using this feature for specific fields and not others which results in a far greater code footprint, and of course as the schema evolves it will require changes to this larger code footprint, making my use of this feature kind of brittle. tldr; can you have prisma generate Just some food for thought - not sure if it's possible or an easy change given you need to accommodate more rdbms than just postgres. |
Is there any intentions for supporting orderByNulls functionality for relations? |
Yes - doing an outer join and ordering by a related field which may be null in the joined table (even if not an optional field on the originating table), would be another great addition to this feature. |
Hey folks,
@jashenco: It is currently not possible to express that via the API. That would look like
@ahammouda Thanks for the suggestion. It's not entirely clear whether that wouldn't bring confusion for the overall API. Don't get me wrong, I understand the benefits of being able to blindly pass
@jack-linden There is but it was intentionally cut out of scope for now to only deal with the low-hanging fruit. I have persisted your feature request here #19761 |
Thanks everyone, |
Please share your feedback about the
orderByNulls
functionality released in v4.1.0 in this issue.If you have any questions, don't hesitate to ask them in the
#prisma-client
channel in the Prisma Slack.The text was updated successfully, but these errors were encountered: