@@ -54,6 +54,8 @@ describe(DynamoDBDocument.name, () => {
54
54
create : null as null | CreateTableCommandOutput ,
55
55
write : { } as Record < string , PutCommandOutput > ,
56
56
read : { } as Record < string , GetCommandOutput > ,
57
+ undefinedColumnWrite : null as null | PutCommandOutput ,
58
+ undefinedColumnRead : null as null | GetCommandOutput ,
57
59
batchWrite : null as null | BatchWriteCommandOutput ,
58
60
batchRead : null as null | BatchGetCommandOutput ,
59
61
transactWrite : null as null | TransactWriteCommandOutput ,
@@ -354,6 +356,30 @@ describe(DynamoDBDocument.name, () => {
354
356
} )
355
357
. catch ( passError ) ;
356
358
359
+ log . undefinedColumnWrite = await doc
360
+ . put ( {
361
+ TableName,
362
+ Item : {
363
+ id : "undefinedColumns" ,
364
+ A : "A" ,
365
+ B : undefined ,
366
+ C : "C" ,
367
+ D : undefined ,
368
+ E : "E" ,
369
+ } ,
370
+ } )
371
+ . catch ( passError ) ;
372
+
373
+ log . undefinedColumnRead = await doc
374
+ . get ( {
375
+ TableName,
376
+ Key : {
377
+ id : "undefinedColumns" ,
378
+ } ,
379
+ ConsistentRead : true ,
380
+ } )
381
+ . catch ( passError ) ;
382
+
357
383
for ( const [ id , value ] of [ [ "1" , data as any ] , ...Object . entries ( data ) ] ) {
358
384
log . update [ id ] = await doc
359
385
. update ( {
@@ -446,7 +472,7 @@ describe(DynamoDBDocument.name, () => {
446
472
// to report the table name
447
473
} ) ;
448
474
449
- it ( "describes the test table tables " , async ( ) => {
475
+ it ( "describes the test table" , async ( ) => {
450
476
if ( log . describe ) {
451
477
expect ( log . describe ?. Table ?. TableName ) . toEqual ( TableName ) ;
452
478
}
@@ -462,6 +488,17 @@ describe(DynamoDBDocument.name, () => {
462
488
}
463
489
} ) ;
464
490
491
+ it ( "ignores undefined column values for backwards compatibility" , async ( ) => {
492
+ throwIfError ( log . undefinedColumnWrite ) ;
493
+
494
+ expect ( log . undefinedColumnRead ?. Item ) . toEqual ( {
495
+ id : "undefinedColumns" ,
496
+ A : "A" ,
497
+ C : "C" ,
498
+ E : "E" ,
499
+ } ) ;
500
+ } ) ;
501
+
465
502
it ( "can batch write" , async ( ) => {
466
503
throwIfError ( log . batchWrite ) ;
467
504
} ) ;
0 commit comments