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

Nullable number columns not supported for sorting #74

Open
jkalberer opened this issue Jan 17, 2023 · 4 comments
Open

Nullable number columns not supported for sorting #74

jkalberer opened this issue Jan 17, 2023 · 4 comments

Comments

@jkalberer
Copy link
Contributor

I can work on a PR for this feature but do you have any idea on the best way I should go about implementing this?

@jkalberer jkalberer changed the title Nullable number columns not supported for sortin Nullable number columns not supported for sorting Jan 17, 2023
@benjamin658
Copy link
Owner

Could you share the entity that was trying to sort?

@jkalberer
Copy link
Contributor Author

jkalberer commented Jan 30, 2023

Yeah, i have a numerical column that is nullable. I'll can get you an entity but it's just a really basic column that fails to serialize when the value is null.

Looking at the logic for this I'm not even sure that a integer column would paginate correctly unless you sorted by multiple columns. If there were many rows with the same value, it would skip over them. Please correct me here if I'm wrong.

@benjamin658
Copy link
Owner

benjamin658 commented Feb 1, 2023

You have to use an unique column as the pagination key.

@jkalberer
Copy link
Contributor Author

In this case I have an entity like:

class Entity {
  @Column({ nullable: true })
  value: number | null;
  
  @CreateDateColumn({ type: 'timestamptz' })
  created: Date;
}

I should be able to do a sort like (for postgres)
ORDER BY value DESC NULLS LAST, created DESC

The problem is that the parsing of nulls is still busted for this use-case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants