FastEasyMapping
FastEasyMapping copied to clipboard
Never ending recursion
Suppose if there is a Parent which has children array inside it and those children also has a children array in It... and so on. This will end when a child doesn't have any more children.
I create a mapping Function for creating a representation and In core DB I have a to many relationship from children to children.
That method that creates a representation i.e. FEMapping for mapping that data.
func parentMapper() -> FEMMapping {
let mapping = FEMMapping(entityName: “Parent”)
mapping.primaryKey = “id”
mapping.addAttributes(from: [“key”, "id", “value”])
mapping.addToManyRelationshipMapping(parentMapper(), forProperty: “children”, keyPath: “children”)
return mapping
}
This mapping function is recursive and never ends.
Hello, @Rico9260
Recursive behaviour comes out of the recursive call to a parentMapper. What you might actually want to is:
func parentMapper() -> FEMMapping {
let mapping = FEMMapping(entityName: “Parent”)
mapping.primaryKey = “id”
mapping.addAttributes(from: [“key”, "id", “value”])
// this will setup a recursive mapping
mapping.addRecursiveToManyRelationship(forProperty: "children", keypath: "children")
return mapping
}