File tree Expand file tree Collapse file tree 3 files changed +83
-3
lines changed Expand file tree Collapse file tree 3 files changed +83
-3
lines changed Original file line number Diff line number Diff line change @@ -581,10 +581,13 @@ export class BasePayload {
581
581
this . config . collections . forEach ( ( collection ) => {
582
582
let customIDType = undefined
583
583
const findCustomID : TraverseFieldsCallback = ( { field, next } ) => {
584
- if ( [ 'array' , 'blocks' ] . includes ( field . type ) ) {
585
- next ( )
586
- return
584
+ if (
585
+ [ 'array' , 'blocks' , 'group' ] . includes ( field . type ) ||
586
+ ( field . type === 'tab' && 'name' in field )
587
+ ) {
588
+ return true
587
589
}
590
+
588
591
if ( ! fieldAffectsData ( field ) ) {
589
592
return
590
593
}
Original file line number Diff line number Diff line change @@ -383,9 +383,46 @@ export default buildConfigWithDefaults({
383
383
] ,
384
384
} ,
385
385
} ,
386
+ {
387
+ name : 'title' ,
388
+ type : 'text' ,
389
+ } ,
386
390
] ,
387
391
versions : { drafts : true } ,
388
392
} ,
393
+ {
394
+ slug : 'fake-custom-ids' ,
395
+ fields : [
396
+ {
397
+ name : 'title' ,
398
+ type : 'text' ,
399
+ } ,
400
+ {
401
+ name : 'group' ,
402
+ type : 'group' ,
403
+ fields : [
404
+ {
405
+ name : 'id' ,
406
+ type : 'text' ,
407
+ } ,
408
+ ] ,
409
+ } ,
410
+ {
411
+ type : 'tabs' ,
412
+ tabs : [
413
+ {
414
+ name : 'myTab' ,
415
+ fields : [
416
+ {
417
+ name : 'id' ,
418
+ type : 'text' ,
419
+ } ,
420
+ ] ,
421
+ } ,
422
+ ] ,
423
+ } ,
424
+ ] ,
425
+ } ,
389
426
{
390
427
slug : 'relationships-migration' ,
391
428
fields : [
Original file line number Diff line number Diff line change @@ -90,6 +90,46 @@ describe('database', () => {
90
90
91
91
expect ( doc . id ) . toBeDefined ( )
92
92
} )
93
+
94
+ it ( 'should not create duplicate versions with custom id type' , async ( ) => {
95
+ const doc = await payload . create ( {
96
+ collection : 'custom-ids' ,
97
+ data : {
98
+ title : 'hey' ,
99
+ } ,
100
+ } )
101
+
102
+ await payload . update ( {
103
+ collection : 'custom-ids' ,
104
+ id : doc . id ,
105
+ data : { } ,
106
+ } )
107
+
108
+ await payload . update ( {
109
+ collection : 'custom-ids' ,
110
+ id : doc . id ,
111
+ data : { } ,
112
+ } )
113
+
114
+ const versionsQuery = await payload . db . findVersions ( {
115
+ collection : 'custom-ids' ,
116
+ req : { } as PayloadRequest ,
117
+ where : {
118
+ 'version.title' : {
119
+ equals : 'hey' ,
120
+ } ,
121
+ latest : {
122
+ equals : true ,
123
+ } ,
124
+ } ,
125
+ } )
126
+
127
+ expect ( versionsQuery . totalDocs ) . toStrictEqual ( 1 )
128
+ } )
129
+
130
+ it ( 'should not accidentally treat nested id fields as custom id' , ( ) => {
131
+ expect ( payload . collections [ 'fake-custom-ids' ] . customIDType ) . toBeUndefined ( )
132
+ } )
93
133
} )
94
134
95
135
describe ( 'timestamps' , ( ) => {
You can’t perform that action at this time.
0 commit comments