Skip to content
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

Index sort order, NULL behavior: NULLS FIRST / NULLS LAST #15466

Open
Tracked by #16311
janpio opened this issue Sep 22, 2022 · 4 comments
Open
Tracked by #16311

Index sort order, NULL behavior: NULLS FIRST / NULLS LAST #15466

janpio opened this issue Sep 22, 2022 · 4 comments
Labels
kind/feature A request for a new feature. status/has-stopgap A stopgap for this functionality has been implemented. team/psl-wg team/schema Issue for team Schema. topic: database-functionality topic: extendedIndexes topic: indexes topic: postgresql

Comments

@janpio
Copy link
Member

janpio commented Sep 22, 2022

Seems our index sort order feature currently only lets your sort ascending or descending, but not define where the NULLs should be put: https://www.prisma.io/docs/concepts/components/prisma-schema/indexes#configuring-the-index-sort-order-with-sort

NULLS FIRST
Specifies that nulls sort before non-nulls. This is the default when DESC is specified.

NULLS LAST
Specifies that nulls sort after non-nulls. This is the default when DESC is not specified.

https://www.postgresql.org/docs/9.6/sql-createindex.html#:~:text=descending%20sort%20order.-,NULLS%20FIRST,-Specifies%20that%20nulls

CREATE INDEX "some_table_some_indexed_col_idx" ON "some_table"("some_indexed_col" DESC nulls last);

Variants of our sort orders that add NullsFirst and NullsLast to the available values seems like an easy way to fix this.

@DavidHancu
Copy link
Contributor

👋 Hi @janpio!

I've been working on my NPM Package Prisma Util, which is all about implementing features that are requested by developers in the community. This issue has attracted my attention and I want to ask if anyone would be interested in this feature being added either to Prisma or Prisma Util.

Prisma Util already has enhanced migration parsing, so it should be able to handle this issue pretty easily.

@janpio
Copy link
Member Author

janpio commented Oct 5, 2022

Well, I work at Prisma so no need to build this for me. It is on our list of issues we are looking into.

@janpio janpio added the status/has-stopgap A stopgap for this functionality has been implemented. label May 11, 2023
@aseemk
Copy link

aseemk commented May 2, 2024

Hi @janpio & team. I just ran into the lack of this. Is this still planned for sometime? Alternately, this seems to be labeled "has-stopgap". Does that mean a workaround is available? What is that workaround if so? Thank you!

@janpio
Copy link
Member Author

janpio commented May 6, 2024

You should be able to generate a migration file, and then modify it before applying: https://www.prisma.io/docs/orm/prisma-migrate/workflows/unsupported-database-features#customize-a-migration-to-include-an-unsupported-feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature A request for a new feature. status/has-stopgap A stopgap for this functionality has been implemented. team/psl-wg team/schema Issue for team Schema. topic: database-functionality topic: extendedIndexes topic: indexes topic: postgresql
Projects
None yet
Development

No branches or pull requests

4 participants