realm / realm-swift

Realm is a mobile database: a replacement for Core Data & SQLite
https://realm.io
Apache License 2.0
16.31k stars 2.14k forks source link

Allow for classes deriving from Object to have different className than name of the class #6624

Open zdzichukowalski opened 4 years ago

zdzichukowalski commented 4 years ago

Assume there is some model for example representing country. Application may have different sources of data, Realm db among others. It is natural that those different entities, e.g. CountryGraphQL, CountryRealm will be transformed to one Country model to be further used by app. It is also natural to have class in Realm db representing country to be named simply Country, not CountryRealm. Issue https://github.com/realm/realm-cocoa/issues/2194 shows that there is simple way to do this (if any).

Granted this could always be circumvented by changing name in the Realm db, or by renaming classes in Swift. But apart from the fact that the new naming may be unsatisfactory this could pose serious problem when developer can't change names in Swift (for example he or she is using some external library and we have name clash), and data comes from external provider, for example via Realm sync.

Please reconsider if the change cannot be made. Maybe this could be achieved via flag determining if the className implementation should be overridden.

BlueCobold commented 2 years ago

I would really like to have this feature in Swift. Just like it exists on Android. Being forced to name a class just like the realm data table is named, is very inconvenient in my case, because it clashes with business model class names.