Throwing C-API when creating object with duplicate primary key

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Major - P3
    • Q3-22FY
    • Affects Version/s: None
    • Component/s: None
    • None

      In the current implementation of the C-API the`realm_object_create_with_primary_key`-function acts as a find or create and will return the existing object if one already existed.

      In Kotlin we would like to throw an error if the user tries to create objects with duplicate primary keys, similarly to other SDKs (Java, Cocoa).

      I think it would be most consistent if the `realm_object_create_with_primary_key` would raise an error (through returning a null pointer and checking the `last_error`) and introduce a new call for the upsert variant. This way the `RLM_ERR_DUPLICATE_PRIMARY_KEY_VALUE` error value could be used consistently when ever the unique constraint was violated across the API.

            Assignee:
            Jørgen Edelbo (Inactive)
            Reporter:
            Claus Rørbech (Inactive)
            Archiver:
            Marc Greenfield

              Created:
              Updated:
              Resolved:
              Archived: