realm-java icon indicating copy to clipboard operation
realm-java copied to clipboard

Align @PrimaryKey nullability with Cocoa

Open cmelchior opened this issue 11 years ago • 9 comments

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.

cmelchior avatar Nov 12 '15 18:11 cmelchior

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.

cmelchior avatar Nov 12 '15 21:11 cmelchior

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

ghost avatar Dec 11 '15 11:12 ghost

Yes, we fully agree. This is also why it is labeled as a bug.

cmelchior avatar Dec 11 '15 11:12 cmelchior

@rimeissner The problem you mentioned has been fixed by #2003 :beers:

beeender avatar Jan 08 '16 07:01 beeender

@beeender :tada: thanks for the update :smile:

ghost avatar Jan 08 '16 08:01 ghost

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.

cmelchior avatar Feb 10 '16 14:02 cmelchior

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.

stk1m1 avatar Feb 18 '16 08:02 stk1m1

This task consist of the following sub tasks (most likely all different PR's / issues). Determine progress / deadline on #1445 before starting this:

  • [ ] Rename @PrimaryKey to @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 @Index or @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

cmelchior avatar Feb 18 '16 11:02 cmelchior

Fixed by https://github.com/realm/realm-java/pull/2634 and part of 0.89

cmelchior avatar Apr 21 '16 19:04 cmelchior