1
0
Fork 0
mirror of synced 2024-08-23 05:51:29 +12:00

Fix sorting in pg

This commit is contained in:
Adria Navarro 2024-05-21 16:08:22 +02:00
parent 8cf021f254
commit 53605ec8ed

View file

@ -387,7 +387,13 @@ class InternalBuilder {
for (let [key, value] of Object.entries(sort)) {
const direction =
value.direction === SortDirection.ASCENDING ? "asc" : "desc"
query = query.orderBy(`${aliased}.${key}`, direction)
let nulls
if (this.client === SqlClient.POSTGRES) {
// All other clients already sort this as expected by default, and adding this to the rest of the clients is causing issues
nulls = value.direction === SortDirection.ASCENDING ? "first" : "last"
}
query = query.orderBy(`${aliased}.${key}`, direction, nulls)
}
} else if (this.client === SqlClient.MS_SQL && paginate?.limit) {
// @ts-ignore