-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
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.