-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(db-postgres): select hasMany inside arrays and blocks with versio…
…ns (#10829) Fixes #10780 Previously, with enabled versions, nested select `hasMany: true` fields weren't working with SQL database adapters. This was due to wrongly passed `parent` to select rows data because we store arrays and blocks in versions a bit differently, using both, `id` and `_uuid` (which contains the normal Object ID) columns. And unlike with non versions `_uuid` column isn't actually applicable here as it's not unique, thus we need to save blocks/arrays first and then map their ObjectIDs to generated by the database IDs and use them for select fields `parent` data
- Loading branch information
Showing
8 changed files
with
170 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import type { CollectionConfig } from 'payload' | ||
|
||
import { selectVersionsFieldsSlug } from '../../slugs.js' | ||
|
||
const SelectVersionsFields: CollectionConfig = { | ||
slug: selectVersionsFieldsSlug, | ||
versions: true, | ||
fields: [ | ||
{ | ||
type: 'select', | ||
hasMany: true, | ||
options: ['a', 'b', 'c'], | ||
name: 'hasMany', | ||
}, | ||
{ | ||
type: 'array', | ||
name: 'array', | ||
fields: [ | ||
{ | ||
type: 'select', | ||
hasMany: true, | ||
options: ['a', 'b', 'c'], | ||
name: 'hasManyArr', | ||
}, | ||
], | ||
}, | ||
{ | ||
type: 'blocks', | ||
name: 'blocks', | ||
blocks: [ | ||
{ | ||
slug: 'block', | ||
fields: [ | ||
{ | ||
type: 'select', | ||
hasMany: true, | ||
options: ['a', 'b', 'c'], | ||
name: 'hasManyBlocks', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
} | ||
|
||
export default SelectVersionsFields |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters