Uploaded image for project: 'Realm Kotlin'
  1. Realm Kotlin
  2. RKOTLIN-696

Extend `@PersistedName` annotation to apply to classes

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • Q2-24FY
    • Affects Version/s: None
    • Component/s: None
    • None

      Similar to @PersistedName for fields (see #590), we should provide the option of mapping Kotlin class names to their underlying (persisted) name.

      Unable to find source-code formatter for language: kt. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      @PersistedName(name = "myPersistedName")
      class Example : RealmObject {
          // ...
      }
      

      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

      [ ] Add a CLASS annotation target to PersistedName.kt.
      [ ] Modify AccessorModifierIrGeneration.modifyPropertiesAndCollectSchema to account for persisted values (perhaps no changes needed here).
      [ ] Modify RealmModelSyntheticPropertiesGeneration (see addSchemaMethodBody() where irClass.name.identifier is used, maybe other places as well).
      [ ] Validate that persisted and public names are a unique in the Realm. 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 persisted name, not the public (Kotlin) name in the model class.

      // Step 3

      [ ] Verify that queries can use both persisted and public names in queries.

            Assignee:
            christian.melchior@mongodb.com Christian Melchior (Inactive)
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: