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

[feature request] Unique/Index column collate / case-(in)sensitive

Open smarek opened this issue 5 years ago • 2 comments

Annotation @Unique is currently missing ability to mark string unique index case-sensitive/case-insensitive, previously this function was proposed in https://github.com/objectbox/objectbox-java/issues/20#issuecomment-335006482

@Entity public class User {
  @Id public long id;
  @Unique(caseSensitive=true) String username;
  @Unique(caseSensitive=false) String email;
}

This might as well be replaced by more manual setting of collate

@Entity public class User {
  @Id public long id;
  @Unique(collate=CollateType.BINARY) String username; // or none, as BINARY is default
  @Unique(collate=CollateType.NOCASE) String email;
}

Could this feature be added?

Is it possible to somehow achieve schema setting (UNIQUE (email COLLATE NOCASE)) right now with ObjectBox version 2.5.0, or impossible without adding support in the library?

smarek avatar Jan 09 '20 14:01 smarek

Thanks. Looking at the conversation in #20 I guess it was decided to keep it simple and always have a case sensitive unique index. But this was so long ago I don't remember details.

I'll guess we can leave this open for others to thumbs up.

greenrobot-team avatar Jan 13 '20 09:01 greenrobot-team

@greenrobot-team well simplicity is one thing, but being unable to set collate for index (not just unique indexes) is imho missing functionality

See docs https://www.sqlite.org/datatype3.html#collation

smarek avatar Jan 13 '20 13:01 smarek

Moving the discussion about improving support for other languages to #46.

greenrobot-team avatar Nov 15 '22 06:11 greenrobot-team