@@ -24,7 +24,6 @@ use common::{
24
24
} ,
25
25
} ;
26
26
use database:: LegacyIndexDiff ;
27
- use maplit:: btreemap;
28
27
#[ cfg( any( test, feature = "testing" ) ) ]
29
28
use proptest:: prelude:: * ;
30
29
use serde:: {
@@ -418,50 +417,24 @@ impl TryFrom<ConvexObject> for DeploymentAuditLogEvent {
418
417
} ,
419
418
"clear_tables" => DeploymentAuditLogEvent :: ClearTables ,
420
419
"snapshot_import" => {
421
- let first_entry = match fields. get ( "table_names" ) {
422
- Some ( ConvexValue :: Array ( a) ) => a. first ( ) . cloned ( ) ,
423
- v => anyhow:: bail!( "expected array for table_names, got {v:?}" ) ,
424
- } ;
425
- let table_names: BTreeMap < _ , _ > = match first_entry {
426
- None => btreemap ! ( ) ,
427
- Some ( ConvexValue :: String ( _) ) => btreemap ! (
428
- ComponentPath :: root( ) => remove_vec_of_strings( & mut fields, "table_names" ) ?
429
- . iter( )
430
- . map( |s| TableName :: from_str( s) )
431
- . try_collect( ) ?,
432
- ) ,
433
- Some ( ConvexValue :: Object ( _) ) => remove_vec ( & mut fields, "table_names" ) ?
434
- . into_iter ( )
435
- . map ( |v| {
436
- let o: ConvexObject = v. try_into ( ) ?;
437
- let mut fields = BTreeMap :: from ( o) ;
438
- let component = ComponentPath :: deserialize (
439
- remove_nullable_string ( & mut fields, "component" ) ?. as_deref ( ) ,
440
- ) ?;
441
- let table_names: Vec < _ > =
442
- remove_vec_of_strings ( & mut fields, "table_names" ) ?
443
- . iter ( )
444
- . map ( |s| TableName :: from_str ( s) )
445
- . try_collect ( ) ?;
446
- anyhow:: Ok ( ( component, table_names) )
447
- } )
448
- . try_collect ( ) ?,
449
- _ => anyhow:: bail!( "Unknown table_names field type" ) ,
450
- } ;
451
-
452
- let first_entry = match fields. get ( "table_names_deleted" ) {
453
- Some ( ConvexValue :: Array ( a) ) => a. first ( ) . cloned ( ) ,
454
- v => anyhow:: bail!( "expected array for table_names, got {v:?}" ) ,
455
- } ;
456
- let table_names_deleted: BTreeMap < _ , _ > = match first_entry {
457
- None => btreemap ! ( ) ,
458
- Some ( ConvexValue :: String ( _) ) => btreemap ! (
459
- ComponentPath :: root( ) => remove_vec_of_strings( & mut fields, "table_names_deleted" ) ?
460
- . iter( )
461
- . map( |s| TableName :: from_str( s) )
462
- . try_collect( ) ?,
463
- ) ,
464
- Some ( ConvexValue :: Object ( _) ) => remove_vec ( & mut fields, "table_names_deleted" ) ?
420
+ let table_names: BTreeMap < _ , _ > = remove_vec ( & mut fields, "table_names" ) ?
421
+ . into_iter ( )
422
+ . map ( |v| {
423
+ let o: ConvexObject = v. try_into ( ) ?;
424
+ let mut fields = BTreeMap :: from ( o) ;
425
+ let component = ComponentPath :: deserialize (
426
+ remove_nullable_string ( & mut fields, "component" ) ?. as_deref ( ) ,
427
+ ) ?;
428
+ let table_names: Vec < _ > =
429
+ remove_vec_of_strings ( & mut fields, "table_names" ) ?
430
+ . iter ( )
431
+ . map ( |s| TableName :: from_str ( s) )
432
+ . try_collect ( ) ?;
433
+ anyhow:: Ok ( ( component, table_names) )
434
+ } )
435
+ . try_collect ( ) ?;
436
+ let table_names_deleted: BTreeMap < _ , _ > =
437
+ remove_vec ( & mut fields, "table_names_deleted" ) ?
465
438
. into_iter ( )
466
439
. map ( |v| {
467
440
let o: ConvexObject = v. try_into ( ) ?;
@@ -476,9 +449,7 @@ impl TryFrom<ConvexObject> for DeploymentAuditLogEvent {
476
449
. try_collect ( ) ?;
477
450
anyhow:: Ok ( ( component, table_names) )
478
451
} )
479
- . try_collect ( ) ?,
480
- _ => anyhow:: bail!( "Unknown table_names_deleted field type" ) ,
481
- } ;
452
+ . try_collect ( ) ?;
482
453
DeploymentAuditLogEvent :: SnapshotImport {
483
454
table_names,
484
455
table_count : remove_int64 ( & mut fields, "table_count" ) ? as u64 ,
0 commit comments