@@ -23,6 +23,8 @@ pub struct AnalyzedTargetSetupState {
2323 pub setup_key : serde_json:: Value ,
2424 pub desired_setup_state : serde_json:: Value ,
2525 pub setup_by_user : bool ,
26+ /// None for declarations.
27+ pub key_schema : Option < Arc < [ schema:: FieldSchema ] > > ,
2628}
2729
2830pub struct AnalyzedSetupState {
@@ -121,15 +123,19 @@ fn build_target_id(
121123 let mut compatible_target_ids = HashSet :: < Option < i32 > > :: new ( ) ;
122124 let mut reusable_schema_version_ids = HashSet :: < Option < i32 > > :: new ( ) ;
123125 for existing_state in existing_target_states. iter ( ) . flat_map ( |v| v. iter ( ) ) {
124- let compatibility =
125- if analyzed_target_ss. setup_by_user == existing_state. common . setup_by_user {
126- target_factory. check_state_compatibility (
127- & analyzed_target_ss. desired_setup_state ,
128- & existing_state. state ,
129- ) ?
130- } else {
131- SetupStateCompatibility :: NotCompatible
132- } ;
126+ let compatibility = if let Some ( key_schema) = & analyzed_target_ss. key_schema
127+ && let Some ( existing_key_schema) = & existing_state. common . key_schema
128+ && key_schema != existing_key_schema
129+ {
130+ SetupStateCompatibility :: NotCompatible
131+ } else if analyzed_target_ss. setup_by_user != existing_state. common . setup_by_user {
132+ SetupStateCompatibility :: NotCompatible
133+ } else {
134+ target_factory. check_state_compatibility (
135+ & analyzed_target_ss. desired_setup_state ,
136+ & existing_state. state ,
137+ ) ?
138+ } ;
133139 let compatible_target_id = if compatibility != SetupStateCompatibility :: NotCompatible {
134140 reusable_schema_version_ids. insert (
135141 ( compatibility == SetupStateCompatibility :: Compatible )
@@ -184,6 +190,7 @@ fn build_target_id(
184190 schema_version_id,
185191 max_schema_version_id : max_schema_version_id. max ( schema_version_id) ,
186192 setup_by_user : analyzed_target_ss. setup_by_user ,
193+ key_schema : analyzed_target_ss. key_schema . clone ( ) ,
187194 } ,
188195 state : analyzed_target_ss. desired_setup_state . clone ( ) ,
189196 } ) ;
0 commit comments