mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-11 18:01:59 +00:00
Fix pg numeric sort (#7261)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
a6c6c79f3a
commit
33295a9420
@ -85,6 +85,7 @@ import {
|
|||||||
isDataField,
|
isDataField,
|
||||||
isOwner,
|
isOwner,
|
||||||
type JoinProps,
|
type JoinProps,
|
||||||
|
NumericTypes,
|
||||||
parseDoc,
|
parseDoc,
|
||||||
parseDocWithProjection,
|
parseDocWithProjection,
|
||||||
parseUpdate,
|
parseUpdate,
|
||||||
@ -920,7 +921,12 @@ abstract class PostgresAdapterBase implements DbAdapter {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if (typeof val === 'number') {
|
if (typeof val === 'number') {
|
||||||
res.push(`${this.getKey(_class, baseDomain, key, joins)} ${val === 1 ? 'ASC' : 'DESC'}`)
|
const attr = this.hierarchy.findAttribute(_class, key)
|
||||||
|
if (attr !== undefined && NumericTypes.includes(attr.type._class)) {
|
||||||
|
res.push(`(${this.getKey(_class, baseDomain, key, joins)})::numeric ${val === 1 ? 'ASC' : 'DESC'}`)
|
||||||
|
} else {
|
||||||
|
res.push(`${this.getKey(_class, baseDomain, key, joins)} ${val === 1 ? 'ASC' : 'DESC'}`)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// todo handle custom sorting
|
// todo handle custom sorting
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,13 @@ export async function retryTxn (
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const NumericTypes = [
|
||||||
|
core.class.TypeNumber,
|
||||||
|
core.class.TypeTimestamp,
|
||||||
|
core.class.TypeDate,
|
||||||
|
core.class.Collection
|
||||||
|
]
|
||||||
|
|
||||||
export async function createTables (client: postgres.Sql, domains: string[]): Promise<void> {
|
export async function createTables (client: postgres.Sql, domains: string[]): Promise<void> {
|
||||||
const filtered = domains.filter((d) => !loadedDomains.has(d))
|
const filtered = domains.filter((d) => !loadedDomains.has(d))
|
||||||
if (filtered.length === 0) {
|
if (filtered.length === 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user