You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the implementation will serialize an array of enums to an array of ordinal values.
Using the Juice enum example from the documentation: [Juice.ORANGE, Juice.GRAPE] will be stored as [0, 2]
I think there are a few difficulties with this approach:
If the order of enums is changed, this will change the ordinal values. As result, aren't you going to get wrong enums when existing record are read? E.g.:
Assume we have [0,2] stored. If we change the enum to
static enum Juice {
ORANGE(0),
GRAPE(2),
APPLE(1)
}
Shouldn't we get [Juice.ORANGE, Juice.APPLE] instead of original [Juice.ORANGE, Juice.GRAPE] ?
Btw, if ordinal values are used, why do we have value field in Juice? Aren't these 2 unrelated?
If the table is used by other teams/tools we need to share mapping of our ordinal values to enum names with them. It would be much more descriptive if we just had varchars...
GORM will map an Enum field to a varchar type. So it would make more sense to map Enum[] to varchar[]
The text was updated successfully, but these errors were encountered:
First of all I'm sorry for taking too much time to answer this issue.
Currently I'm working on migrating all the Java code to Groovy + @CompileStatic and I'm studying the file in which these mappings are done BidiEnumMap.
I'm not the original author of this code and I don't remember why we did this but after analyzing the code I think you're right. It seems strange to store the ids instead of just storing the value itself.
I'll ask with @Alotor after my holidays because he did the code but I think we should change this to just store the value.
Currently the implementation will serialize an array of enums to an array of ordinal values.
Using the Juice enum example from the documentation:
[Juice.ORANGE, Juice.GRAPE]
will be stored as[0, 2]
I think there are a few difficulties with this approach:
Assume we have
[0,2]
stored. If we change the enum toShouldn't we get
[Juice.ORANGE, Juice.APPLE]
instead of original[Juice.ORANGE, Juice.GRAPE]
?Btw, if ordinal values are used, why do we have
value
field inJuice
? Aren't these 2 unrelated?The text was updated successfully, but these errors were encountered: