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

Realm does not support subclassing from RLMObject subclasses #906

Closed
mergesort opened this issue Sep 14, 2014 · 2 comments
Closed

Realm does not support subclassing from RLMObject subclasses #906

mergesort opened this issue Sep 14, 2014 · 2 comments

Comments

@mergesort
Copy link

When doing OO programming, it's quite a common behavior to have a base super class which can have properties such as created_at, updated_at, or whatever your all subclassed models will need. When using a common ORM like ActiveRecord, all of the objects inherit from ActiveRecord::Base, and the model often has a has_one relationship with what it's "inheriting", it's not really an expected behavior in the functionality that Realm is attempting to provide.

If the goal of Realm is to abstract away the database side of your code and treat persisted models as regular models, then it would make sense to support direct subclassing of objects which inherit from RLMObject. Besides clarity, this would have the added benefit of lowering the barrier for someone who to add persistence into a project which does not have it, without re-architecting the models, in the same way that CoreData allows.

@timanglade
Copy link
Contributor

Thanks for the write-up @mergesort. We definitely want to allow something like this, be it via inheritance or via composition. It’s hard to do well (read: while maintaining performance with millions of objects composed from a complex hierarchy of inheritances), but we have a few ideas we’re working on…

@alazier
Copy link
Contributor

alazier commented Sep 29, 2014

This is now supported in master with #940

@alazier alazier closed this as completed Sep 29, 2014
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants