checkpoint

This commit is contained in:
2026-04-09 18:39:52 -04:00
parent 9387152859
commit 5f45df6c11
11 changed files with 677 additions and 467 deletions

View File

@ -131,13 +131,33 @@ impl Merger {
pub(crate) fn merge_internal(
&self,
schema: Arc<crate::database::schema::Schema>,
mut schema: Arc<crate::database::schema::Schema>,
data: Value,
notifications: &mut Vec<String>,
) -> Result<Value, String> {
match data {
Value::Array(items) => self.merge_array(schema, items, notifications),
Value::Object(map) => self.merge_object(schema, map, notifications),
Value::Object(map) => {
if let Some(options) = schema.obj.compiled_options.get() {
if let Some(disc) = schema.obj.compiled_discriminator.get() {
let val = map.get(disc).and_then(|v| v.as_str());
if let Some(v) = val {
if let Some(target_id) = options.get(v) {
if let Some(target_schema) = self.db.schemas.get(target_id) {
schema = Arc::new(target_schema.clone());
} else {
return Err(format!("Polymorphic mapped target '{}' not found in database registry", target_id));
}
} else {
return Err(format!("Polymorphic discriminator {}='{}' matched no compiled options", disc, v));
}
} else {
return Err(format!("Polymorphic merging failed: missing required discriminator '{}'", disc));
}
}
}
self.merge_object(schema, map, notifications)
},
_ => Err("Invalid merge payload: root must be an Object or Array".to_string()),
}
}