@@ -740,7 +740,7 @@ lazy_static! {
740
740
}
741
741
742
742
/// An entity is represented as a map of attribute names to values.
743
- #[ derive( Clone , CacheWeight , PartialEq , Eq , Serialize ) ]
743
+ #[ derive( Clone , CacheWeight , Eq , Serialize ) ]
744
744
pub struct Entity ( Object < Value > ) ;
745
745
746
746
impl < ' a > IntoIterator for & ' a Entity {
@@ -874,10 +874,16 @@ impl Entity {
874
874
}
875
875
876
876
pub fn get ( & self , key : & str ) -> Option < & Value > {
877
+ if key == VID_FIELD {
878
+ return None ;
879
+ }
877
880
self . 0 . get ( key)
878
881
}
879
882
880
883
pub fn contains_key ( & self , key : & str ) -> bool {
884
+ if key == VID_FIELD {
885
+ return false ;
886
+ }
881
887
self . 0 . contains_key ( key)
882
888
}
883
889
@@ -919,7 +925,8 @@ impl Entity {
919
925
/// Return the VID of this entity and if its missing or of a type different than
920
926
/// i64 it panics.
921
927
pub fn vid ( & self ) -> i64 {
922
- self . get ( VID_FIELD )
928
+ self . 0
929
+ . get ( VID_FIELD )
923
930
. expect ( "the vid must be set" )
924
931
. as_int8 ( )
925
932
. expect ( "the vid must be set to a valid value" )
@@ -1062,6 +1069,12 @@ impl Entity {
1062
1069
}
1063
1070
}
1064
1071
1072
+ impl PartialEq for Entity {
1073
+ fn eq ( & self , other : & Self ) -> bool {
1074
+ self . sorted_ref ( ) == other. sorted_ref ( )
1075
+ }
1076
+ }
1077
+
1065
1078
/// Convenience methods to modify individual attributes for tests.
1066
1079
/// Production code should not use/need this.
1067
1080
#[ cfg( debug_assertions) ]
0 commit comments