objectbox / objectbox/objectbox-java

Allow specifying custom type converters per table or globally too

Aperta
#899 1 commento 5 reazioni 1 assegnatario Vedi su GitHub

@greenrobot-team ci sta già lavorando.

Dal 24/8/2020.

enhancement
Lingua principale
Java
Stelle
4.6k
Fork
311
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Currently, to convert a custom type, we have to annotate each field of that type individually with @Convert.
This is very inconvenientt, because if you have a custom type, e.g. joda.time.DateTime you'll always want to convert it, so it would be much cleaner and less error-prone if we could define custom type converters per table or for the whole database too, like Room does it with TypeConverters.

Describe the solution you'd like
For a per-entity definition of converters, one could extend the @Entity annotation something like this:

@Entity(converters={@Convert(...), @Convert(...),...}
public class User ...

For defining converters globally, the ObjectBox builder could be extended.

Describe alternatives you've considered
Currently, the only alternative is to add @Convert to each and every field.

Additional context
As said above, you can have a look at Room's @TypeConverter annotation that can be applied to METHOD, PARAMETER, TYPE and FIELD.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.