Closed eugene-bulkin closed 8 years ago
1 is obviously trivial to implement compared to 2, the question to answer here is whether or not the work required for 2 is worth the benefits it provides. I can definitely see the utility of going from x --> [x]
since the user wouldn't have to reinitialize any of the existing values, and the behavior is basically what you expect it to be. It's harder to define the behavior on the other way back, so perhaps we can just implement it for one direction.
Well, inherent in choice 1 is data being lost. In many cases, we just go from an int to a float, which is something that we wouldn't necessarily want or need to discard. In other cases, we'd go the other way around, which results in some data loss. I, personally, lean toward implementing the option that loses the least data.
As for the array suggestion, I think I might actually be OK with doing it only one-way. Going from x --> [x] is more expected than [x, y, z] --> x or z or default(T)... at least, that is, there are fewer arguable outcomes. So I'm fine with only doing T --> T[] and not the other way around.
If the user is altering a schema to change a property type, what should graphene do with existing values?
T2
T
toT2
; if not possible, use default value for new typeT2
If we choose option 2, then how do we convert
T <--> T[]
? If we go fromT --> T[]
, do we replacex
with[x]
or with[]
? Going the other way, fromT[] --> T
, do we replace[x, y, z]
withx
?z
? Or the default value ofT
?