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
An amazing feature you made there, works as expected for most cases except theres an interesting case.
The query: colors( orderBy:{ main_color: {count: desc} } }
The model: model Color { id Int @id @default(autoincrement()) color_profiles ColorProfile[] products ProductContainer[] hex String @unique background String? main_color SingleProduct[] @relation("MainProductColor") frame_color SingleProduct[] @relation("ProductFrameColor") colors_related Color[] @relation("ColorToColor") // colors related to me (this color) }
Basically, i have Color relations to product properties, a product can have a main color and a frame color etc...
What i want, is to sort by the amount of products this color is associated with (biggest to smallest by frame_color).
It works, when the relation field has connections.
It fails, when the relation field is an empty array. When we have desc, the 0 values are at the top (the arrays that have null connections), then we start to get to the largest values after them and go down (see the picture). When we have 'asc', the null arrays are treated as the highest COUNT aggregate value we start from 1, go to biggest value and we get 0 values (null arrays).
The text was updated successfully, but these errors were encountered:
Hi guys,
An amazing feature you made there, works as expected for most cases except theres an interesting case.
The query:
colors( orderBy:{ main_color: {count: desc} } }
The model:
model Color { id Int @id @default(autoincrement()) color_profiles ColorProfile[] products ProductContainer[] hex String @unique background String? main_color SingleProduct[] @relation("MainProductColor") frame_color SingleProduct[] @relation("ProductFrameColor") colors_related Color[] @relation("ColorToColor") // colors related to me (this color) }
Basically, i have Color relations to product properties, a product can have a main color and a frame color etc...
What i want, is to sort by the amount of products this color is associated with (biggest to smallest by frame_color).
It works, when the relation field has connections.
It fails, when the relation field is an empty array. When we have desc, the 0 values are at the top (the arrays that have null connections), then we start to get to the largest values after them and go down (see the picture). When we have 'asc', the null arrays are treated as the highest COUNT aggregate value we start from 1, go to biggest value and we get 0 values (null arrays).
The text was updated successfully, but these errors were encountered: