mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-21 07:46:24 +00:00
Fix pg set null (#7159)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
b1c50bb8c2
commit
8bec20e0c5
@ -233,7 +233,7 @@ export type ArrayMoveDescriptor<T extends object> = {
|
|||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export type NumberProperties<T extends object> = {
|
export type NumberProperties<T extends object> = {
|
||||||
[P in keyof T]: T[P] extends number | undefined ? T[P] : never
|
[P in keyof T]: T[P] extends number | undefined | null ? T[P] : never
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,9 +177,13 @@ describe('postgres operations', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const doc = (await client.findAll<Task>(taskPlugin.class.Task, {}))[0]
|
const doc = (await client.findAll<Task>(taskPlugin.class.Task, {}))[0]
|
||||||
|
await operations.updateDoc(doc._class, doc.space, doc._id, { rate: null })
|
||||||
|
let tasks = await client.findAll<Task>(taskPlugin.class.Task, {})
|
||||||
|
expect(tasks.length).toEqual(1)
|
||||||
|
expect(tasks[0].rate).toBeNull()
|
||||||
|
|
||||||
await operations.updateDoc(doc._class, doc.space, doc._id, { rate: 30 })
|
await operations.updateDoc(doc._class, doc.space, doc._id, { rate: 30 })
|
||||||
let tasks = await client.findAll<Task>(taskPlugin.class.Task, {})
|
tasks = await client.findAll<Task>(taskPlugin.class.Task, {})
|
||||||
expect(tasks.length).toEqual(1)
|
expect(tasks.length).toEqual(1)
|
||||||
expect(tasks[0].rate).toEqual(30)
|
expect(tasks[0].rate).toEqual(30)
|
||||||
|
|
||||||
@ -205,7 +209,7 @@ describe('postgres operations', () => {
|
|||||||
expect(tasks[0].arr?.length).toEqual(2)
|
expect(tasks[0].arr?.length).toEqual(2)
|
||||||
expect(tasks[0].arr?.[0]).toEqual(1)
|
expect(tasks[0].arr?.[0]).toEqual(1)
|
||||||
expect(tasks[0].arr?.[1]).toEqual(3)
|
expect(tasks[0].arr?.[1]).toEqual(3)
|
||||||
})
|
}, 1000000)
|
||||||
|
|
||||||
it('check remove', async () => {
|
it('check remove', async () => {
|
||||||
for (let i = 0; i < 10; i++) {
|
for (let i = 0; i < 10; i++) {
|
||||||
|
@ -34,7 +34,7 @@ export enum TaskReproduce {
|
|||||||
export interface Task extends Doc {
|
export interface Task extends Doc {
|
||||||
name: string
|
name: string
|
||||||
description: string
|
description: string
|
||||||
rate?: number
|
rate?: number | null
|
||||||
status?: TaskStatus
|
status?: TaskStatus
|
||||||
reproduce?: TaskReproduce
|
reproduce?: TaskReproduce
|
||||||
eta?: TaskEstimate | null
|
eta?: TaskEstimate | null
|
||||||
|
@ -1492,7 +1492,7 @@ class PostgresAdapter extends PostgresAdapterBase {
|
|||||||
for (const key in remainingData) {
|
for (const key in remainingData) {
|
||||||
if (ops[key] === undefined) continue
|
if (ops[key] === undefined) continue
|
||||||
const val = (remainingData as any)[key]
|
const val = (remainingData as any)[key]
|
||||||
from = `jsonb_set(${from}, '{${key}}', to_jsonb($${paramsIndex++}${inferType(val)}) , true)`
|
from = `jsonb_set(${from}, '{${key}}', coalesce(to_jsonb($${paramsIndex++}${inferType(val)}), 'null') , true)`
|
||||||
params.push(val)
|
params.push(val)
|
||||||
dataUpdated = true
|
dataUpdated = true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user