come up with example how to deal with parent child relationships
@@ -104,7 +104,7 @@ impl RelationTemplate {
};
let model_a = {
- let model = relation.with_schema(|schema| schema.find_model(&model_a_name).unwrap());
+ let model = relation.schema().find_model(&model_a_name).unwrap();
let field = model
.fields()
@@ -148,6 +148,12 @@ impl Relation {
}
}
+ fn schema(&self) -> SchemaRef {
+ self.schema.upgrade().unwrap_or(
+ panic!("Schema does not exist anymore. Parent schema is deleted without deleting the child schema.")
+ )
+ }
+
pub fn is_inline_relation(&self) -> bool {
self.manifestation
.as_ref()
