Align @PrimaryKey nullability with Cocoa
Right now Realm Java disallow null as primary key values. Cocoa allow this. They need to agree on this behaviour otherwise.
Also the Javadoc for @PrimaryKey should be updated to reflect any decision being made.
See also https://github.com/realm/realm-cocoa/issues/2849, we might as well combine these two to avoid having breaking this part of the API to often.
Concerning the @PrimaryKey annotation, it would be nice if it behaves the same as the FieldType.PRIMARY_KEY (or other way around). Currently I have to add FieldType.PRIMARY_KEY and FieldType.REQUIRED in the migration else it will break if I annotate a Field with @PrimaryKey
Yes, we fully agree. This is also why it is labeled as a bug.
@rimeissner The problem you mentioned has been fixed by #2003 :beers:
@beeender :tada: thanks for the update :smile:
Internal note: This issue is about migrating our API to what i described in https://github.com/realm/realm-cocoa/issues/2849 + making sure that we have the same behaviors regarding nullability.
It is also expected to see PR #2196 being merged before actual work on this gets started since the PR provide us a chance to handle this elegantly.
This task consist of the following sub tasks (most likely all different PR's / issues). Determine progress / deadline on #1445 before starting this:
- [ ] Rename
@PrimaryKeyto@ObjectId. Keep both syntaxes for a certain amount of time if possible. This is a breaking API change, so will need to be done before 1.0. ObjectId is automatically Unique and Indexed. - [ ] Update method names / JavaDoc in
RealmObjectSchema - [ ] Primary keys should be allowed to be null.
- [ ] Discuss with Cocoa if it should be
@Indexor@Indexed - [ ] Update website documentation.
- [ ] Add
@Unique+ update RealmObjectSchema to support it. Unique is automatically indexed. - [ ] Add support for composite
@ObjectId. Not P1. Needs design. - [ ] Add support for composite
@Unique. Not P1. Needs design.
Corresponding Cocoa issue is here: https://github.com/realm/realm-cocoa/issues/2849
Fixed by https://github.com/realm/realm-java/pull/2634 and part of 0.89