@@ -707,6 +707,29 @@ mod tests {
707707 assert ! ( i32_query. get( & world, a) . is_err( ) ) ;
708708 }
709709
710+ #[ test]
711+ fn query_get_works_across_sparse_removal ( ) {
712+ // Regression test for: https://github.com/bevyengine/bevy/issues/6623
713+ let mut world = World :: new ( ) ;
714+ let a = world. spawn ( ( TableStored ( "abc" ) , SparseStored ( 123 ) ) ) . id ( ) ;
715+ let b = world. spawn ( ( TableStored ( "def" ) , SparseStored ( 456 ) ) ) . id ( ) ;
716+ let c = world
717+ . spawn ( ( TableStored ( "ghi" ) , SparseStored ( 789 ) , B ( 1 ) ) )
718+ . id ( ) ;
719+
720+ let mut query = world. query :: < & TableStored > ( ) ;
721+ assert_eq ! ( query. get( & world, a) . unwrap( ) , & TableStored ( "abc" ) ) ;
722+ assert_eq ! ( query. get( & world, b) . unwrap( ) , & TableStored ( "def" ) ) ;
723+ assert_eq ! ( query. get( & world, c) . unwrap( ) , & TableStored ( "ghi" ) ) ;
724+
725+ world. entity_mut ( b) . remove :: < SparseStored > ( ) ;
726+ world. entity_mut ( c) . remove :: < SparseStored > ( ) ;
727+
728+ assert_eq ! ( query. get( & world, a) . unwrap( ) , & TableStored ( "abc" ) ) ;
729+ assert_eq ! ( query. get( & world, b) . unwrap( ) , & TableStored ( "def" ) ) ;
730+ assert_eq ! ( query. get( & world, c) . unwrap( ) , & TableStored ( "ghi" ) ) ;
731+ }
732+
710733 #[ test]
711734 fn remove_tracking ( ) {
712735 let mut world = World :: new ( ) ;
0 commit comments