Fixed sort bug when two select values were null (#6493)
Fixes https://github.com/twentyhq/twenty/issues/5762 The problem was only happening with a sort on a select type field, also appears with currency type and maybe other types. This was because NULL values were sorted in a random order because the sort function was comparing two NULL values as not equal, so I just added a case for when A === B === NULL.
This commit is contained in:
@ -3,6 +3,7 @@ import { sortAsc, sortDesc, sortNullsFirst, sortNullsLast } from '../sort';
|
||||
describe('sort', () => {
|
||||
describe('sortNullsFirst', () => {
|
||||
it('should sort nulls first', () => {
|
||||
expect(sortNullsFirst(null, null)).toBe(0);
|
||||
expect(sortNullsFirst(null, 'a')).toBe(-1);
|
||||
expect(sortNullsFirst('a', null)).toBe(1);
|
||||
expect(sortNullsFirst('a', 'a')).toBe(0);
|
||||
@ -11,6 +12,7 @@ describe('sort', () => {
|
||||
|
||||
describe('sortNullsLast', () => {
|
||||
it('should sort nulls last', () => {
|
||||
expect(sortNullsFirst(null, null)).toBe(0);
|
||||
expect(sortNullsLast(null, 'a')).toBe(1);
|
||||
expect(sortNullsLast('a', null)).toBe(-1);
|
||||
expect(sortNullsLast('a', 'a')).toBe(0);
|
||||
|
||||
Reference in New Issue
Block a user