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

Object comparison #14

Closed
omiz opened this issue Jun 3, 2022 · 0 comments · Fixed by #20
Closed

Object comparison #14

omiz opened this issue Jun 3, 2022 · 0 comments · Fixed by #20

Comments

@omiz
Copy link
Contributor

omiz commented Jun 3, 2022

So let's assume that we have these Entities

class Person {
    let id: String
    let name: String
    let pets: [Cat]
    
    init(id: String, name: String, pets: [Cat]) {
        self.id = id
        self.name = name
        self.pets = pets
    }
}


class Cat {
    let id: String
    let name: String
    let owner: Person?
    
    init(id: String, name: String, owner: Person?) {
        self.id = id
        self.name = name
        self.owner = owner
    }
}

If I would like to query the cats that are related to a person I would assume that this should be possible

let person1 = Person(id: "SomeID", name: "SomeName", pets: [])

\Cat.owner == person1

but because the Person object does not inherit from Primitive I can not use that expression
instead I'm forced to write it as

\Cat.owner?.id == person1.id

Suggested solution

A fix for this issue could be done by extending the Primitive type to hold Identifiable but that might break the meaning of the Primitive type since Identifiable can be a complex type

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

Successfully merging a pull request may close this issue.

1 participant