Skip to content

Inverse Relationships #11

Description

@tkohout

Hi,
I started using modified version of CoreValue on one of my projects and one problem with CoreValue became imminent.

let employee = Employee(objectID: nil, name: "John Doe", age: 18, position: "Clerk", department: "Carpet", job: "Cleaner", shop:nil)
var shop = Shop(objectID: nil, name: "Carpet shop", employees: [employee])

try! shop.save(context)
//Will crash in infinite loop
let shops:[Shop] = Shop.query(context, predicate: nil)

The Employee have inverse relationship with Shop. When I add employee to the Shop entity and save the corevalue will populate the inverse relationship. When I try to query the Shop program will crash in infinite loop.

This is of course logical, because we are working with structs, but it gets quite limiting. The solution is to not to unbox the inverse relationship but I found out that sometimes I need to use both sides of relationship.

I wonder if you are aware of the problem and if you have and idea how to solve it

Thanks

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions