typeorm-cursor-pagination
typeorm-cursor-pagination copied to clipboard
Nullable number columns not supported for sorting
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?
Could you share the entity that was trying to sort?
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.
You have to use an unique column as the pagination key.
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.