Adding Postgres NULLS LAST to an Ash prepare build sort

Hi! I spent a little bit trying to figure this out and wanted to share to make it more searchable. Ash's sorts actually support NULLS FIRST and NULLS LAST as different options passed instead of the normal :asc, :desc, etc:
prepare build(sort: [published_at: :desc_nils_last, inserted_at: :desc])
prepare build(sort: [published_at: :desc_nils_last, inserted_at: :desc])
The documentation references nils, rather than Postgres NULLS, so it didn't come up. https://ash-hq.org/docs/module/ash/latest/ash-sort#type-sort_order-0 Thanks!
Ash HQ
Module: Ash.Sort
View the documentation for Ash.Sort on Ash HQ.
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?