Skip to content

Commit d5d9d93

Browse files
authored
Neo4j order nulls last always (#3277)
1 parent 249d157 commit d5d9d93

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/core/database/query/sorting.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ export const sortWith = <Field extends string>(
6767
query.comment`sorting(${input.sort})`
6868
.subQuery('*', (sub) => matcher(sub, subInput))
6969
.with('*')
70-
.orderBy(`${transformerRef.current('sortValue')}`, order);
70+
.apply((query) => {
71+
const val = String(transformerRef.current('sortValue'));
72+
return order === 'ASC'
73+
? query.orderBy(val)
74+
: query.orderBy([`${val} IS NOT NULL`, val], order);
75+
});
7176
};
7277

7378
/**

0 commit comments

Comments
 (0)