orderBy
: Make nulls: 'first' | 'last'
available on non-nullable fields
#19760
Labels
kind/feature
A request for a new feature.
team/client
Issue for team Client.
tech/engines
Issue for tech Engines.
topic: null
topic: orderBy / sorting
topic: orderByNulls
`{ sort: 'asc', nulls: 'last' }` and similar
Overview
I'd like to request the behavior of generated types to change 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
otherValue
it does not. The reason being that the generated type for the find many args ofvalue
is simplyPrisma.SortOrder
whereas forotherValue
it isPrisma.SortOrderInput | Prisma.SortOrder
. This is frustrating in my particular case because I'm using postgres, and I can simply pass the nulls argument directly to a non-nullable field, and things just work (I realize there's a no-op here):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
Prisma.SortOrderInput | Prisma.SortOrder
types for sortable field arguments regardless of whether the field is nullable or not?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.
Originally posted by @ahammouda in #14377 (comment)
The text was updated successfully, but these errors were encountered: