fix(db-postgres): allow to clear select fields with hasMany: true (#9464)
### What?
Previously, using Postgres, select fields with `hasMany: true` weren't
clearable.
Meaning, you couldn't pass an empty array:
```ts
const updatedDoc = await payload.update({
id,
collection: 'select-fields',
data: {
selectHasMany: [],
},
})
```
### Why?
To achieve the same behavior with MongoDB.
### How?
Modifies logic in `packages/drizzle/src/upsertRow/index.ts` to include
empty arrays.
This commit is contained in:
@@ -521,6 +521,25 @@ describe('Fields', () => {
|
||||
expect(updatedDoc.selectHasMany).toEqual(['one', 'two'])
|
||||
})
|
||||
|
||||
it('should clear select hasMany field', async () => {
|
||||
const { id } = await payload.create({
|
||||
collection: 'select-fields',
|
||||
data: {
|
||||
selectHasMany: ['one', 'two'],
|
||||
},
|
||||
})
|
||||
|
||||
const updatedDoc = await payload.update({
|
||||
id,
|
||||
collection: 'select-fields',
|
||||
data: {
|
||||
selectHasMany: [],
|
||||
},
|
||||
})
|
||||
|
||||
expect(updatedDoc.selectHasMany).toHaveLength(0)
|
||||
})
|
||||
|
||||
it('should query hasMany in', async () => {
|
||||
const hit = await payload.create({
|
||||
collection: 'select-fields',
|
||||
|
||||
Reference in New Issue
Block a user