Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Never ending recursion #113

Open
rajatkj opened this issue Jun 1, 2018 · 1 comment
Open

Never ending recursion #113

rajatkj opened this issue Jun 1, 2018 · 1 comment

Comments

@rajatkj
Copy link

rajatkj commented Jun 1, 2018

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.

@dimazen
Copy link
Contributor

dimazen commented Jun 1, 2018

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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants