mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-09 09:20:54 +00:00
Fix invalid sql query from findAll with empty sort (#9135)
* Add test for empty sort for findAll in postgres * Do not add ORDER BY without order fields --------- Signed-off-by: Nikolay Marchuk <nikolay.marchuk@hardcoreeng.com>
This commit is contained in:
parent
b6e8fdd409
commit
73f7cfc11b
@ -247,6 +247,9 @@ describe('postgres operations', () => {
|
||||
|
||||
const sortDesc = await client.findAll(taskPlugin.class.Task, {}, { sort: { name: SortingOrder.Descending } })
|
||||
expect(sortDesc[0].name).toMatch('my-task-4')
|
||||
|
||||
const sortEmpty = await client.findAll(taskPlugin.class.Task, {}, { sort: {} })
|
||||
expect(sortEmpty).toHaveLength(5)
|
||||
})
|
||||
|
||||
it('check attached', async () => {
|
||||
|
@ -522,7 +522,11 @@ abstract class PostgresAdapterBase implements DbAdapter {
|
||||
// todo handle custom sorting
|
||||
}
|
||||
}
|
||||
return `ORDER BY ${res.join(', ')}`
|
||||
if (res.length > 0) {
|
||||
return `ORDER BY ${res.join(', ')}`
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
buildRawQuery<T extends Doc>(
|
||||
@ -1170,7 +1174,11 @@ abstract class PostgresAdapterBase implements DbAdapter {
|
||||
// todo handle custom sorting
|
||||
}
|
||||
}
|
||||
return `ORDER BY ${res.join(', ')}`
|
||||
if (res.length > 0) {
|
||||
return `ORDER BY ${res.join(', ')}`
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
private buildQuery<T extends Doc>(
|
||||
|
Loading…
Reference in New Issue
Block a user