fix(db-postgres): select hasMany inside arrays and blocks with versions (#10829)
Fixes https://github.com/payloadcms/payload/issues/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
This commit is contained in:
@@ -34,6 +34,7 @@ export interface Config {
|
||||
lexicalObjectReferenceBug: LexicalObjectReferenceBug;
|
||||
users: User;
|
||||
LexicalInBlock: LexicalInBlock;
|
||||
'select-versions-fields': SelectVersionsField;
|
||||
'array-fields': ArrayField;
|
||||
'block-fields': BlockField;
|
||||
'checkbox-fields': CheckboxField;
|
||||
@@ -79,6 +80,7 @@ export interface Config {
|
||||
lexicalObjectReferenceBug: LexicalObjectReferenceBugSelect<false> | LexicalObjectReferenceBugSelect<true>;
|
||||
users: UsersSelect<false> | UsersSelect<true>;
|
||||
LexicalInBlock: LexicalInBlockSelect<false> | LexicalInBlockSelect<true>;
|
||||
'select-versions-fields': SelectVersionsFieldsSelect<false> | SelectVersionsFieldsSelect<true>;
|
||||
'array-fields': ArrayFieldsSelect<false> | ArrayFieldsSelect<true>;
|
||||
'block-fields': BlockFieldsSelect<false> | BlockFieldsSelect<true>;
|
||||
'checkbox-fields': CheckboxFieldsSelect<false> | CheckboxFieldsSelect<true>;
|
||||
@@ -452,6 +454,30 @@ export interface LexicalInBlock {
|
||||
updatedAt: string;
|
||||
createdAt: string;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "select-versions-fields".
|
||||
*/
|
||||
export interface SelectVersionsField {
|
||||
id: string;
|
||||
hasMany?: ('a' | 'b' | 'c')[] | null;
|
||||
array?:
|
||||
| {
|
||||
hasManyArr?: ('a' | 'b' | 'c')[] | null;
|
||||
id?: string | null;
|
||||
}[]
|
||||
| null;
|
||||
blocks?:
|
||||
| {
|
||||
hasManyArr?: ('a' | 'b' | 'c')[] | null;
|
||||
id?: string | null;
|
||||
blockName?: string | null;
|
||||
blockType: 'block';
|
||||
}[]
|
||||
| null;
|
||||
updatedAt: string;
|
||||
createdAt: string;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "array-fields".
|
||||
@@ -1804,6 +1830,10 @@ export interface PayloadLockedDocument {
|
||||
relationTo: 'LexicalInBlock';
|
||||
value: string | LexicalInBlock;
|
||||
} | null)
|
||||
| ({
|
||||
relationTo: 'select-versions-fields';
|
||||
value: string | SelectVersionsField;
|
||||
} | null)
|
||||
| ({
|
||||
relationTo: 'array-fields';
|
||||
value: string | ArrayField;
|
||||
@@ -2074,6 +2104,32 @@ export interface LexicalInBlockSelect<T extends boolean = true> {
|
||||
updatedAt?: T;
|
||||
createdAt?: T;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "select-versions-fields_select".
|
||||
*/
|
||||
export interface SelectVersionsFieldsSelect<T extends boolean = true> {
|
||||
hasMany?: T;
|
||||
array?:
|
||||
| T
|
||||
| {
|
||||
hasManyArr?: T;
|
||||
id?: T;
|
||||
};
|
||||
blocks?:
|
||||
| T
|
||||
| {
|
||||
block?:
|
||||
| T
|
||||
| {
|
||||
hasManyArr?: T;
|
||||
id?: T;
|
||||
blockName?: T;
|
||||
};
|
||||
};
|
||||
updatedAt?: T;
|
||||
createdAt?: T;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "array-fields_select".
|
||||
|
||||
Reference in New Issue
Block a user