-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Local
-
None
-
?
-
5
-
590
-
Needed
-
Kotlin Beta sprint 41, Kotlin Beta sprint 42, Kotlin Beta sprint 43
Similar to Realm Java, we should provide the option of mapping Kotlin field names to their underlying (persisted) representation:
class Example : RealmObject { @PersistedName(name = "myPersistedName") var myKotlinName: String = "" }
In Realm Java, we allow for different naming strategies, overriding all names at once. This idea was pulled from GSON, but I'm not sure it is worth porting to Java as it didn't seemed to be used really.
Other API's will also be affected by this:
- RealmClass should return the persisted name, not the public (Kotlin) name.
- RQL queries should support both the persisted and public names.
TODO:
// Step 1
- [ ] Create PersistedName annotation in io.realm.kotlin.types.annotations
- [ ] Modify AccessorModifierIrGeneration.modifyPropertiesAndCollectSchema to account for internal values
- [ ] Modify RealmModelSyntheticPropertiesGeneration (see line 501, maybe other places)
- [ ] Validate that persisted and public names are a unique set. They are not allowed to overlap. This check should happen at compile time.
- [ ] Verify in Realm Studio that schema is modified correctly
// Step 2
- [ ] Make sure that RealmClass returns the mapped values, not public names in the model class.
// Step 3
- [ ] Modify PropertyInfo to correctly set publicName
- [ ] Verify that queries can use both persisted and public names in queries.
- is depended on by
-
RKOTLIN-696 Extend `@PersistedName` annotation to apply to classes
- Closed