@@ -585,31 +585,39 @@ impl<P: Provider + Sync + Send + Clone + 'static> Executor<'_, P> {
585585 if entity. is_historical {
586586 entity_counter += 1 ;
587587
588+ let ( world_address, entity_id) = entity
589+ . entity_id
590+ . split_once ( ':' )
591+ . expect ( "Invalid world-scoped ID format" ) ;
588592 let data = serde_json:: to_string ( & entity. ty . to_json_value ( ) ?)
589593 . map_err ( |e| ExecutorQueryError :: Parse ( ParseError :: FromJsonStr ( e) ) ) ?;
590594 if let Some ( keys) = entity. keys_str {
591595 sqlx:: query (
592596 "INSERT INTO entities_historical (id, keys, event_id, data, model_id, \
593- executed_at) VALUES (?, ?, ?, ?, ?, ?) RETURNING *",
597+ executed_at, world_address, entity_id ) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING *",
594598 )
595599 . bind ( entity. entity_id . clone ( ) )
596600 . bind ( keys)
597601 . bind ( entity. event_id . clone ( ) )
598602 . bind ( data)
599603 . bind ( entity. model_id . clone ( ) )
600604 . bind ( entity. block_timestamp . clone ( ) )
605+ . bind ( world_address)
606+ . bind ( entity_id)
601607 . fetch_one ( & mut * * tx)
602608 . await ?;
603609 } else {
604610 sqlx:: query (
605611 "INSERT INTO entities_historical (id, event_id, data, model_id, \
606- executed_at) VALUES (?, ?, ?, ?, ?) RETURNING *",
612+ executed_at, world_address, entity_id ) VALUES (?, ?, ?, ?, ?, ?, ?) RETURNING *",
607613 )
608614 . bind ( entity. entity_id . clone ( ) )
609615 . bind ( entity. event_id . clone ( ) )
610616 . bind ( data)
611617 . bind ( entity. model_id . clone ( ) )
612618 . bind ( entity. block_timestamp . clone ( ) )
619+ . bind ( world_address)
620+ . bind ( entity_id)
613621 . fetch_one ( & mut * * tx)
614622 . await ?;
615623 }
@@ -749,18 +757,24 @@ impl<P: Provider + Sync + Send + Clone + 'static> Executor<'_, P> {
749757 if em_query. is_historical {
750758 event_counter += 1 ;
751759
760+ let ( world_address, entity_id) = em_query
761+ . entity_id
762+ . split_once ( ':' )
763+ . expect ( "Invalid world-scoped ID format" ) ;
752764 let data = serde_json:: to_string ( & em_query. ty . to_json_value ( ) ?)
753765 . map_err ( |e| ExecutorQueryError :: Parse ( ParseError :: FromJsonStr ( e) ) ) ?;
754766 sqlx:: query (
755767 "INSERT INTO event_messages_historical (id, keys, event_id, data, \
756- model_id, executed_at) VALUES (?, ?, ?, ?, ?, ?) RETURNING *",
768+ model_id, executed_at, world_address, entity_id ) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING *",
757769 )
758770 . bind ( em_query. entity_id . clone ( ) )
759771 . bind ( em_query. keys_str . clone ( ) )
760772 . bind ( em_query. event_id . clone ( ) )
761773 . bind ( data)
762774 . bind ( em_query. model_id . clone ( ) )
763775 . bind ( em_query. block_timestamp . clone ( ) )
776+ . bind ( world_address)
777+ . bind ( entity_id)
764778 . fetch_one ( & mut * * tx)
765779 . await ?;
766780 }
0 commit comments