PHB-CS123 / graphene

CS123 Graph Database Project
Apache License 2.0
0 stars 0 forks source link

How to handle CHANGE PROPERTY for ALTER TYPE #47

Closed eugene-bulkin closed 8 years ago

eugene-bulkin commented 8 years ago

If the user is altering a schema to change a property type, what should graphene do with existing values?

  1. Discard and replace with default value for new type T2
  2. Attempt to convert from T to T2; if not possible, use default value for new type T2

If we choose option 2, then how do we convert T <--> T[]? If we go from T --> T[], do we replace x with [x] or with []? Going the other way, from T[] --> T, do we replace [x, y, z] with x? z? Or the default value of T?

codyhan94 commented 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.

eugene-bulkin commented 8 years ago

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.